Skip to content

Commit

Permalink
Revert "Throw exception if decay is requested for a field with multip…
Browse files Browse the repository at this point in the history
…le values"

This reverts commit f7fc261.

see #3960 (comment)
  • Loading branch information
brwe committed Apr 24, 2014
1 parent f7fc261 commit a64962b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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;
Expand Down Expand Up @@ -284,9 +283,6 @@ public GeoFieldDataScoreFunction(GeoPoint origin, double scale, double decay, do
@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) {
Expand Down Expand Up @@ -334,9 +330,6 @@ public NumericFieldDataScoreFunction(double origin, double scale, double decay,

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,40 +702,5 @@ public void testNoQueryGiven() throws Exception {
"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));
}

}

0 comments on commit a64962b

Please sign in to comment.