Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
final DocumentMapper docMapper;
final MapperService mapperService = context.getMapperService();
String type = mapperService.documentMapper().type();
docMapper = mapperService.documentMapper(type);
docMapper = mapperService.documentMapper();
for (BytesReference document : documents) {
docs.add(docMapper.parse(new SourceToParse(context.index().getName(), "_temp_id", document, documentXContentType)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void init() throws Exception {
.startObject("properties").startObject(queryField).field("type", "percolator").endObject().endObject()
.endObject().endObject());
mapperService.merge("type", new CompressedXContent(percolatorMapper), MapperService.MergeReason.MAPPING_UPDATE);
fieldMapper = (PercolatorFieldMapper) mapperService.documentMapper("type").mappers().getMapper(queryField);
fieldMapper = (PercolatorFieldMapper) mapperService.documentMapper().mappers().getMapper(queryField);
fieldType = (PercolatorFieldMapper.FieldType) fieldMapper.fieldType();

queries = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void testExtractTerms() throws Exception {
TermQuery termQuery2 = new TermQuery(new Term("field", "term2"));
bq.add(termQuery2, Occur.SHOULD);

DocumentMapper documentMapper = mapperService.documentMapper("doc");
DocumentMapper documentMapper = mapperService.documentMapper();
PercolatorFieldMapper fieldMapper = (PercolatorFieldMapper) documentMapper.mappers().getMapper(fieldName);
IndexMetaData build = IndexMetaData.builder("")
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
Expand Down Expand Up @@ -236,7 +236,7 @@ public void testExtractRanges() throws Exception {
.rangeQuery(15, 20, true, true, null, null, null, null);
bq.add(rangeQuery2, Occur.MUST);

DocumentMapper documentMapper = mapperService.documentMapper("doc");
DocumentMapper documentMapper = mapperService.documentMapper();
IndexMetaData build = IndexMetaData.builder("")
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
.numberOfShards(1).numberOfReplicas(0).build();
Expand Down Expand Up @@ -290,7 +290,7 @@ public void testExtractRanges() throws Exception {
public void testExtractTermsAndRanges_failed() throws Exception {
addQueryFieldMappings();
TermRangeQuery query = new TermRangeQuery("field1", new BytesRef("a"), new BytesRef("z"), true, true);
DocumentMapper documentMapper = mapperService.documentMapper("doc");
DocumentMapper documentMapper = mapperService.documentMapper();
PercolatorFieldMapper fieldMapper = (PercolatorFieldMapper) documentMapper.mappers().getMapper(fieldName);
IndexMetaData build = IndexMetaData.builder("")
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
Expand All @@ -309,7 +309,7 @@ public void testExtractTermsAndRanges_failed() throws Exception {
public void testExtractTermsAndRanges_partial() throws Exception {
addQueryFieldMappings();
PhraseQuery phraseQuery = new PhraseQuery("field", "term");
DocumentMapper documentMapper = mapperService.documentMapper("doc");
DocumentMapper documentMapper = mapperService.documentMapper();
PercolatorFieldMapper fieldMapper = (PercolatorFieldMapper) documentMapper.mappers().getMapper(fieldName);
IndexMetaData build = IndexMetaData.builder("")
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
Expand Down Expand Up @@ -458,7 +458,7 @@ public void testExtractTermsAndRanges_numberFields() throws Exception {
public void testPercolatorFieldMapper() throws Exception {
addQueryFieldMappings();
QueryBuilder queryBuilder = termQuery("field", "value");
ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory
.jsonBuilder()
.startObject()
Expand All @@ -477,7 +477,7 @@ public void testPercolatorFieldMapper() throws Exception {

// add an query for which we don't extract terms from
queryBuilder = rangeQuery("field").from("a").to("z");
doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
.jsonBuilder()
.startObject()
.field(fieldName, queryBuilder)
Expand All @@ -503,7 +503,7 @@ public void testStoringQueries() throws Exception {
// (it can't use shard data for rewriting purposes, because percolator queries run on MemoryIndex)

for (QueryBuilder query : queries) {
ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.field(fieldName, query)
.endObject()),
Expand All @@ -517,7 +517,7 @@ public void testQueryWithRewrite() throws Exception {
addQueryFieldMappings();
client().prepareIndex("remote").setId("1").setSource("field", "value").get();
QueryBuilder queryBuilder = termsLookupQuery("field", new TermsLookup("remote", "1", "field"));
ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory
.jsonBuilder()
.startObject()
Expand All @@ -538,7 +538,7 @@ public void testQueryWithRewrite() throws Exception {
public void testPercolatorFieldMapperUnMappedField() throws Exception {
addQueryFieldMappings();
MapperParsingException exception = expectThrows(MapperParsingException.class, () -> {
mapperService.documentMapper("doc").parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
mapperService.documentMapper().parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
.jsonBuilder()
.startObject()
.field(fieldName, termQuery("unmapped_field", "value"))
Expand All @@ -552,7 +552,7 @@ public void testPercolatorFieldMapperUnMappedField() throws Exception {

public void testPercolatorFieldMapper_noQuery() throws Exception {
addQueryFieldMappings();
ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1", BytesReference
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", BytesReference
.bytes(XContentFactory
.jsonBuilder()
.startObject()
Expand All @@ -561,7 +561,7 @@ public void testPercolatorFieldMapper_noQuery() throws Exception {
assertThat(doc.rootDoc().getFields(fieldType.queryBuilderField.name()).length, equalTo(0));

try {
mapperService.documentMapper("doc").parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
mapperService.documentMapper().parse(new SourceToParse("test", "1", BytesReference.bytes(XContentFactory
.jsonBuilder()
.startObject()
.nullField(fieldName)
Expand Down Expand Up @@ -597,7 +597,7 @@ public void testMultiplePercolatorFields() throws Exception {
mapperService.merge(typeName, new CompressedXContent(percolatorMapper), MapperService.MergeReason.MAPPING_UPDATE);

QueryBuilder queryBuilder = matchQuery("field", "value");
ParsedDocument doc = mapperService.documentMapper(typeName).parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(jsonBuilder().startObject()
.field("query_field1", queryBuilder)
.field("query_field2", queryBuilder)
Expand Down Expand Up @@ -627,7 +627,7 @@ public void testNestedPercolatorField() throws Exception {
mapperService.merge(typeName, new CompressedXContent(percolatorMapper), MapperService.MergeReason.MAPPING_UPDATE);

QueryBuilder queryBuilder = matchQuery("field", "value");
ParsedDocument doc = mapperService.documentMapper(typeName).parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(jsonBuilder().startObject().startObject("object_field")
.field("query_field", queryBuilder)
.endObject().endObject()),
Expand All @@ -636,7 +636,7 @@ public void testNestedPercolatorField() throws Exception {
BytesRef queryBuilderAsBytes = doc.rootDoc().getField("object_field.query_field.query_builder_field").binaryValue();
assertQueryBuilder(queryBuilderAsBytes, queryBuilder);

doc = mapperService.documentMapper(typeName).parse(new SourceToParse("test", "1",
doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(jsonBuilder().startObject()
.startArray("object_field")
.startObject().field("query_field", queryBuilder).endObject()
Expand All @@ -648,7 +648,7 @@ public void testNestedPercolatorField() throws Exception {
assertQueryBuilder(queryBuilderAsBytes, queryBuilder);

MapperParsingException e = expectThrows(MapperParsingException.class, () -> {
mapperService.documentMapper(typeName).parse(new SourceToParse("test", "1",
mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(jsonBuilder().startObject()
.startArray("object_field")
.startObject().field("query_field", queryBuilder).endObject()
Expand Down Expand Up @@ -733,7 +733,7 @@ public void testImplicitlySetDefaultScriptLang() throws Exception {
query.endObject();
query.endObject();

ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.rawField(fieldName, new BytesArray(Strings.toString(query)).streamInput(), query.contentType())
.endObject()),
Expand Down Expand Up @@ -771,7 +771,7 @@ public void testImplicitlySetDefaultScriptLang() throws Exception {
query.endObject();
query.endObject();

doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.rawField(fieldName, new BytesArray(Strings.toString(query)).streamInput(), query.contentType())
.endObject()),
Expand Down Expand Up @@ -857,7 +857,7 @@ public void testDuplicatedClauses() throws Exception {
QueryBuilder qb = boolQuery()
.must(boolQuery().must(termQuery("field", "value1")).must(termQuery("field", "value2")))
.must(boolQuery().must(termQuery("field", "value2")).must(termQuery("field", "value3")));
ParsedDocument doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
ParsedDocument doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.field(fieldName, qb)
.endObject()),
Expand All @@ -879,7 +879,7 @@ public void testDuplicatedClauses() throws Exception {
.must(boolQuery().must(termQuery("field", "value2")).must(termQuery("field", "value3")))
.must(boolQuery().must(termQuery("field", "value3")).must(termQuery("field", "value4")))
.must(boolQuery().should(termQuery("field", "value4")).should(termQuery("field", "value5")));
doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.field(fieldName, qb)
.endObject()),
Expand All @@ -904,7 +904,7 @@ public void testDuplicatedClauses() throws Exception {
.should(boolQuery().should(termQuery("field", "value2")).should(termQuery("field", "value3")))
.should(boolQuery().should(termQuery("field", "value3")).should(termQuery("field", "value4")))
.should(boolQuery().should(termQuery("field", "value4")).should(termQuery("field", "value5")));
doc = mapperService.documentMapper("doc").parse(new SourceToParse("test", "1",
doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
BytesReference.bytes(XContentFactory.jsonBuilder().startObject()
.field(fieldName, qb)
.endObject()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {

public void testSizeEnabled() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type", "_size", "enabled=true");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
DocumentMapper docMapper = service.mapperService().documentMapper();

BytesReference source = BytesReference
.bytes(XContentFactory.jsonBuilder()
Expand All @@ -70,7 +70,7 @@ public void testSizeEnabled() throws Exception {

public void testSizeDisabled() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type", "_size", "enabled=false");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
DocumentMapper docMapper = service.mapperService().documentMapper();

BytesReference source = BytesReference
.bytes(XContentFactory.jsonBuilder()
Expand All @@ -84,7 +84,7 @@ public void testSizeDisabled() throws Exception {

public void testSizeNotSet() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
DocumentMapper docMapper = service.mapperService().documentMapper();

BytesReference source = BytesReference
.bytes(XContentFactory.jsonBuilder()
Expand All @@ -98,7 +98,7 @@ public void testSizeNotSet() throws Exception {

public void testThatDisablingWorksWhenMerging() throws Exception {
IndexService service = createIndex("test", Settings.EMPTY, "type", "_size", "enabled=true");
DocumentMapper docMapper = service.mapperService().documentMapper("type");
DocumentMapper docMapper = service.mapperService().documentMapper();
assertThat(docMapper.metadataMapper(SizeFieldMapper.class).enabled(), is(true));

String disabledMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected GetFieldMappingsResponse shardOperation(final GetFieldMappingsIndexReq

Map<String, Map<String, FieldMappingMetaData>> typeMappings = new HashMap<>();
for (String type : typeIntersection) {
DocumentMapper documentMapper = indexService.mapperService().documentMapper(type);
DocumentMapper documentMapper = indexService.mapperService().documentMapper();
Map<String, FieldMappingMetaData> fieldMapping = findFieldMappingsByType(fieldPredicate, documentMapper, request);
if (!fieldMapping.isEmpty()) {
typeMappings.put(type, fieldMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Builder(RootObjectMapper.Builder builder, MapperService mapperService) {
this.rootObjectMapper = builder.build(builderContext);

final String type = rootObjectMapper.name();
final DocumentMapper existingMapper = mapperService.documentMapper(type);
final DocumentMapper existingMapper = mapperService.documentMapper();
final Version indexCreatedVersion = mapperService.getIndexSettings().getIndexVersionCreated();
final Map<String, TypeParser> metadataMapperParsers =
mapperService.mapperRegistry.getMetadataMapperParsers(indexCreatedVersion);
Expand Down
Loading