remove check and test for more than one mapper per field
This commit is contained in:
parent
691ac8e105
commit
592e637293
|
@ -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<FieldMapper> 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);
|
||||
|
|
|
@ -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<SearchResponse> 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");
|
||||
|
|
Loading…
Reference in New Issue