From 592e637293fff3a83a8fd6fc0047f0f0c14b8f20 Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Wed, 14 Aug 2013 12:52:46 +0200 Subject: [PATCH] remove check and test for more than one mapper per field --- .../functionscore/DecayFunctionParser.java | 11 +------- .../DecayFunctionScoreTests.java | 25 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java index 53c21476eb5..97725dd8a1f 100644 --- a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java +++ b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java @@ -35,7 +35,6 @@ import org.elasticsearch.index.fielddata.GeoPointValues; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; @@ -47,7 +46,6 @@ import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParse import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; -import java.util.List; /** * This class provides the basic functionality needed for adding a decay @@ -149,14 +147,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser { throw new QueryParsingException(parseContext.index(), "Unknown field [" + fieldName + "]"); } - FieldMappers mappers = smartMappers.fieldMappers(); - List allMappers = mappers.mappers(); - if (allMappers.size() != 1) { - throw new QueryParsingException(parseContext.index(), "The field name [" + fieldName - + "] is ambiguous! Please set the full name of the field"); - } - FieldMapper mapper = allMappers.get(0); - + FieldMapper mapper = smartMappers.fieldMappers().mapper(); // dates and time need special handling if (mapper instanceof DateFieldMapper) { return parseDateVariable(fieldName, parser, parseContext, (DateFieldMapper) mapper); diff --git a/src/test/java/org/elasticsearch/test/integration/search/functionscore/DecayFunctionScoreTests.java b/src/test/java/org/elasticsearch/test/integration/search/functionscore/DecayFunctionScoreTests.java index f0ce083514b..93e1d9217f3 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/functionscore/DecayFunctionScoreTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/functionscore/DecayFunctionScoreTests.java @@ -337,31 +337,6 @@ public class DecayFunctionScoreTests extends AbstractSharedClusterTest { } - @Test(expected = SearchPhaseExecutionException.class) - public void testParsingExceptionIfMultipleFieldsWithSameName() throws Exception { - createIndexMapped("test", "type", "test", "string", "num", "double"); - ensureYellow(); - int numDocs = 2; - - // so, we added a mapping for "type", but now we index "type1". - // this will result in two fields "type.num" and "type1.num" - client().index( - indexRequest("test").type("type1").source(jsonBuilder().startObject().field("test", "value").field("num", 1).endObject())) - .actionGet(); - refresh(); - DecayFunctionBuilder gfb3 = new LinearDecayFunctionBuilder(); - gfb3.setParameters("num", Integer.toString(numDocs), Integer.toString(numDocs / 2)); - - ActionFuture response = client().search( - searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source( - searchSource() - .explain(true) - .size(numDocs) - .query(functionScoreQuery(termQuery("test", "value")).add(new MatchAllFilterBuilder(), gfb3).scoreMode( - "multiply")))); - response.actionGet(); - } - @Test(expected = SearchPhaseExecutionException.class) public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { createIndexMapped("test", "type", "test", "string", "num", "string");