Revert "Throw exception if decay is requested for a field with multiple values"

This reverts commit 95d781510f.

see https://github.com/elasticsearch/elasticsearch/issues/3960#issuecomment-41279373
This commit is contained in:
Britta Weber 2014-04-24 15:43:04 +02:00
parent 95d781510f
commit e84d3111a3
2 changed files with 0 additions and 42 deletions

View File

@ -22,7 +22,6 @@ package org.elasticsearch.index.query.functionscore;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.search.ComplexExplanation;
import org.apache.lucene.search.Explanation;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.geo.GeoDistance;
@ -284,9 +283,6 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
@Override
public void setNextReader(AtomicReaderContext context) {
geoPointValues = fieldData.load(context).getGeoPointValues();
if (geoPointValues.isMultiValued()) {
throw new ElasticsearchException("Field " + fieldData.getFieldNames().fullName() + " is multy valued. Cannot compute decay for more than one value.");
}
}
private final GeoPoint getValue(int doc, GeoPoint missing) {
@ -334,9 +330,6 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
public void setNextReader(AtomicReaderContext context) {
this.doubleValues = this.fieldData.load(context).getDoubleValues();
if (doubleValues.isMultiValued()) {
throw new ElasticsearchException("Field " + fieldData.getFieldNames().fullName() + "is multy valued. Cannot compute decay for more than one value.");
}
}
private final double getValue(int doc, double missing) {

View File

@ -702,40 +702,5 @@ public class DecayFunctionScoreTests extends ElasticsearchIntegrationTest {
"multiply"))));
response.actionGet();
}
@Test
public void testMultiValuedFieldException() throws Throwable {
assertAcked(prepareCreate("test").addMapping(
"type",
jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "string")
.endObject().startObject("num").field("type", "double").endObject().startObject("geo").field("type", "geo_point")
.endObject().endObject().endObject().endObject()));
ensureYellow();
double[] numVals = { 1.0, 2.0, 3.0 };
client().index(
indexRequest("test").type("type").source(
jsonBuilder().startObject().field("test", "value").field("num", numVals).field("geo").startArray().startObject()
.field("lat", 1).field("lon", 1).endObject().startObject().field("lat", 1).field("lon", 2).endObject().endArray()
.endObject())).actionGet();
refresh();
SearchResponse response = client().prepareSearch("test")
.setQuery(functionScoreQuery().add(new MatchAllFilterBuilder(), linearDecayFunction("num", 1, 0.5)).scoreMode("multiply"))
.execute().actionGet();
assertThat(response.getShardFailures().length, equalTo(1));
assertThat(response.getHits().getHits().length, equalTo(0));
List<Float> lonlat = new ArrayList<Float>();
lonlat.add(new Float(1));
lonlat.add(new Float(1));
response = client().prepareSearch("test")
.setQuery(functionScoreQuery().add(new MatchAllFilterBuilder(), linearDecayFunction("geo", lonlat, "1000km")).scoreMode("multiply"))
.execute().actionGet();
assertThat(response.getShardFailures().length, equalTo(1));
assertThat(response.getHits().getHits().length, equalTo(0));
}
}