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 @@ -93,10 +93,9 @@ public void setup() {
.put("index.analysis.analyzer.text_shingle_unigram.tokenizer", "whitespace")
.put("index.analysis.analyzer.text_shingle_unigram.filter", "lowercase, shingle_unigram")
.build();
indexService = createIndex(
indexService = createIndexWithSimpleMappings(
"test",
settings,
"t",
"text_shingle",
"type=text,analyzer=text_shingle",
"text_shingle_unigram",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class NeedsScoreTests extends OpenSearchSingleNodeTestCase {

public void testNeedsScores() {
IndexService index = createIndex("test", Settings.EMPTY, "type", "d", "type=double");
IndexService index = createIndexWithSimpleMappings("test", Settings.EMPTY, "d", "type=double");

Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
contexts.put(NumberSortScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testDefaults() throws IOException {

public void testFilterExecutionContext() throws IOException {
ScriptService scriptService = getInstanceFromNode(ScriptService.class);
IndexService indexService = createIndex("index", Settings.EMPTY, "doc", "field", "type=long");
IndexService indexService = createIndexWithSimpleMappings("index", Settings.EMPTY, "field", "type=long");

Request.ContextSetup contextSetup = new Request.ContextSetup("index", new BytesArray("{\"field\": 3}"), null);
contextSetup.setXContentType(MediaTypeRegistry.JSON);
Expand Down Expand Up @@ -120,7 +120,7 @@ public void testFilterExecutionContext() throws IOException {

public void testScoreExecutionContext() throws IOException {
ScriptService scriptService = getInstanceFromNode(ScriptService.class);
IndexService indexService = createIndex("index", Settings.EMPTY, "doc", "rank", "type=long", "text", "type=text");
IndexService indexService = createIndexWithSimpleMappings("index", Settings.EMPTY, "rank", "type=long", "text", "type=text");

Request.ContextSetup contextSetup = new Request.ContextSetup(
"index",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void testPercolateQueryWithNestedDocuments_doLeakFieldDataCacheEntries()

public void testMapUnmappedFieldAsText() throws IOException {
Settings.Builder settings = Settings.builder().put("index.percolator.map_unmapped_fields_as_text", true);
createIndex("test", settings.build(), "query", "query", "type=percolator");
createIndexWithSimpleMappings("test", settings.build(), "query", "type=percolator");
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "value")).endObject())
Expand All @@ -302,10 +302,9 @@ public void testMapUnmappedFieldAsText() throws IOException {
}

public void testRangeQueriesWithNow() throws Exception {
IndexService indexService = createIndex(
IndexService indexService = createIndexWithSimpleMappings(
"test",
Settings.builder().put("index.number_of_shards", 1).build(),
"_doc",
"field1",
"type=keyword",
"field2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
}

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

BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject());
Expand All @@ -77,7 +77,7 @@ public void testSizeEnabled() throws Exception {
}

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

BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject());
Expand All @@ -87,7 +87,7 @@ public void testSizeDisabled() throws Exception {
}

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

BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject());
Expand All @@ -97,7 +97,7 @@ public void testSizeNotSet() throws Exception {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import org.opensearch.index.engine.MergedSegmentWarmerFactory;
import org.opensearch.index.engine.NoOpEngine;
import org.opensearch.index.flush.FlushStats;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.mapper.SourceToParse;
import org.opensearch.index.seqno.RetentionLeaseSyncer;
import org.opensearch.index.seqno.SequenceNumbers;
Expand Down Expand Up @@ -477,7 +476,7 @@ public void testMaybeRollTranslogGeneration() throws Exception {
.put("index.number_of_shards", 1)
.put("index.translog.generation_threshold_size", generationThreshold + "b")
.build();
createIndex("test", settings, MapperService.SINGLE_MAPPING_NAME);
createIndexWithSimpleMappings("test", settings);
ensureGreen("test");
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
final IndexService test = indicesService.indexService(resolveIndex("test"));
Expand Down Expand Up @@ -813,7 +812,7 @@ public void testShardChangesWithDefaultDocType() throws Exception {
.put("index.translog.flush_threshold_size", "512mb") // do not flush
.put("index.soft_deletes.enabled", true)
.build();
IndexService indexService = createIndex("index", settings, "user_doc", "title", "type=keyword");
IndexService indexService = createIndexWithSimpleMappings("index", settings, "title", "type=keyword");
int numOps = between(1, 10);
for (int i = 0; i < numOps; i++) {
if (randomBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public class FiltersAggsRewriteIT extends OpenSearchSingleNodeTestCase {

public void testWrapperQueryIsRewritten() throws IOException {
createIndex("test", Settings.EMPTY, "test", "title", "type=text");
createIndexWithSimpleMappings("test", Settings.EMPTY, "title", "type=text");
client().prepareIndex("test").setId("1").setSource("title", "foo bar baz").get();
client().prepareIndex("test").setId("2").setSource("title", "foo foo foo").get();
client().prepareIndex("test").setId("3").setSource("title", "bar baz bax").get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOExceptio
.put("index.analysis.filter.my_delimited_payload.encoding", encodingString)
.put("index.analysis.filter.my_delimited_payload.type", "mock_payload_filter")
.build();
createIndex("test", setting, "type1", mapping);
createIndex("test", setting, mapping);

client().prepareIndex("test")
.setId(Integer.toString(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void testThatAnalyzersAreUsedInMapping() throws IOException {
.endObject()
.endObject()
.endObject();
MapperService mapperService = createIndex("test", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("test", indexSettings, mapping).mapperService();

MappedFieldType fieldType = mapperService.fieldType("field");
assertThat(fieldType.getTextSearchInfo().getSearchAnalyzer(), instanceOf(NamedAnalyzer.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testDerivedValueFetching() throws IOException {
}

private ConstantKeywordFieldMapper getMapper(FieldMapper.CopyTo copyTo) {
indexService = createIndex("test-index", Settings.EMPTY, "constant_keyword", "field", "type=constant_keyword,value=default_value");
indexService = createIndexWithSimpleMappings("test-index", Settings.EMPTY, "field", "type=constant_keyword,value=default_value");
ConstantKeywordFieldMapper mapper = (ConstantKeywordFieldMapper) indexService.mapperService()
.documentMapper()
.mappers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ public void testIndexSortWithNestedFieldsWithOlderVersion() throws IOException {
Settings settings = settings(Version.V_3_0_0).put("index.sort.field", "foo").build();
IllegalArgumentException invalidNestedException = expectThrows(
IllegalArgumentException.class,
() -> createIndex("test", settings, "t", "nested_field", "type=nested", "foo", "type=keyword")
() -> createIndexWithSimpleMappings("test", settings, "nested_field", "type=nested", "foo", "type=keyword")
);
assertThat(invalidNestedException.getMessage(), containsString("cannot have nested fields when index sort is activated"));
IndexService indexService = createIndex("test", settings, "t", "foo", "type=keyword");
IndexService indexService = createIndexWithSimpleMappings("test", settings, "foo", "type=keyword");
CompressedXContent nestedFieldMapping = new CompressedXContent(
BytesReference.bytes(
XContentFactory.jsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ public void testParentObjectMapperAreNested() throws Exception {
MapperService mapperService = createIndex(
"index1",
Settings.EMPTY,
"_doc",
jsonBuilder().startObject()
.startObject("properties")
.startObject("comments")
Expand All @@ -901,7 +900,6 @@ public void testParentObjectMapperAreNested() throws Exception {
mapperService = createIndex(
"index2",
Settings.EMPTY,
"_doc",
jsonBuilder().startObject()
.startObject("properties")
.startObject("comments")
Expand Down Expand Up @@ -1107,7 +1105,6 @@ public void testMergeNestedMappings() throws IOException {
MapperService mapperService = createIndex(
"index1",
Settings.EMPTY,
MapperService.SINGLE_MAPPING_NAME,
jsonBuilder().startObject()
.startObject("properties")
.startObject("nested1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testConflictFieldsMapping(String fieldName) throws Exception {
}

protected void testConflictWhileMergingAndMappingUnchanged(XContentBuilder mapping, XContentBuilder mappingUpdate) throws IOException {
IndexService indexService = createIndex("test", Settings.builder().build(), MapperService.SINGLE_MAPPING_NAME, mapping);
IndexService indexService = createIndex("test", Settings.builder().build(), mapping);
CompressedXContent mappingBeforeUpdate = indexService.mapperService().documentMapper().mappingSource();
// simulate like in MetadataMappingService#putMapping
try {
Expand Down Expand Up @@ -111,8 +111,7 @@ public void testConflictSameType() throws Exception {
.endObject()
.endObject()
.endObject();
MapperService mapperService = createIndex("test", Settings.builder().build(), MapperService.SINGLE_MAPPING_NAME, mapping)
.mapperService();
MapperService mapperService = createIndex("test", Settings.builder().build(), mapping).mapperService();

XContentBuilder update = XContentFactory.jsonBuilder()
.startObject()
Expand Down Expand Up @@ -158,8 +157,7 @@ public void testConflictNewType() throws Exception {
.endObject()
.endObject()
.endObject();
MapperService mapperService = createIndex("test", Settings.builder().build(), MapperService.SINGLE_MAPPING_NAME, mapping)
.mapperService();
MapperService mapperService = createIndex("test", Settings.builder().build(), mapping).mapperService();

XContentBuilder update = XContentFactory.jsonBuilder()
.startObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void setUp() throws Exception {
.endObject()
.endObject()
.endObject();
indexService = createIndex("index", Settings.EMPTY, "type", mapping);
indexService = createIndex("index", Settings.EMPTY, mapping);
mapperService = indexService.mapperService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public void testMultiLevelNestedSorting() throws IOException {
mapping.endObject();
}
mapping.endObject();
IndexService indexService = createIndex("nested_sorting", Settings.EMPTY, "_doc", mapping);
IndexService indexService = createIndex("nested_sorting", Settings.EMPTY, mapping);

List<List<Document>> books = new ArrayList<>();
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testResolveLegacySimilarity() throws IOException {
.endObject()
.endObject();

MapperService mapperService = createIndex("foo", settings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", settings, mapping).mapperService();
assertThat(mapperService.fieldType("dummy").getTextSearchInfo().getSimilarity().get(), instanceOf(LegacyBM25Similarity.class));
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public void testResolveSimilaritiesFromMapping_bm25() throws IOException {
.put("index.similarity.my_similarity.b", 0.5f)
.put("index.similarity.my_similarity.discount_overlaps", false)
.build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
assertThat(mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(), instanceOf(BM25Similarity.class));

BM25Similarity similarity = (BM25Similarity) mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get();
Expand All @@ -156,7 +156,7 @@ public void testResolveSimilaritiesFromMapping_boolean() throws IOException {
.endObject()
.endObject();

MapperService mapperService = createIndex("foo", Settings.EMPTY, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", Settings.EMPTY, mapping).mapperService();
assertThat(mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(), instanceOf(BooleanSimilarity.class));
}

Expand All @@ -178,7 +178,7 @@ public void testResolveSimilaritiesFromMapping_DFR() throws IOException {
.put("index.similarity.my_similarity.normalization", "h2")
.put("index.similarity.my_similarity.normalization.h2.c", 3f)
.build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
assertThat(mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(), instanceOf(DFRSimilarity.class));

DFRSimilarity similarity = (DFRSimilarity) mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get();
Expand Down Expand Up @@ -206,7 +206,7 @@ public void testResolveSimilaritiesFromMapping_IB() throws IOException {
.put("index.similarity.my_similarity.normalization", "h2")
.put("index.similarity.my_similarity.normalization.h2.c", 3f)
.build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
assertThat(mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(), instanceOf(IBSimilarity.class));

IBSimilarity similarity = (IBSimilarity) mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get();
Expand All @@ -231,7 +231,7 @@ public void testResolveSimilaritiesFromMapping_DFI() throws IOException {
.put("index.similarity.my_similarity.type", "DFI")
.put("index.similarity.my_similarity.independence_measure", "chisquared")
.build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
MappedFieldType fieldType = mapperService.fieldType("field1");

assertThat(fieldType.getTextSearchInfo().getSimilarity().get(), instanceOf(DFISimilarity.class));
Expand All @@ -255,7 +255,7 @@ public void testResolveSimilaritiesFromMapping_LMDirichlet() throws IOException
.put("index.similarity.my_similarity.mu", 3000f)
.build();

MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
assertThat(mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(), instanceOf(LMDirichletSimilarity.class));

LMDirichletSimilarity similarity = (LMDirichletSimilarity) mapperService.fieldType("field1")
Expand All @@ -280,7 +280,7 @@ public void testResolveSimilaritiesFromMapping_LMJelinekMercer() throws IOExcept
.put("index.similarity.my_similarity.type", "LMJelinekMercer")
.put("index.similarity.my_similarity.lambda", 0.7f)
.build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MapperService mapperService = createIndex("foo", indexSettings, mapping).mapperService();
assertThat(
mapperService.fieldType("field1").getTextSearchInfo().getSimilarity().get(),
instanceOf(LMJelinekMercerSimilarity.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testTook() throws Exception {
.endObject()
.endObject()
.endObject();
createIndex("test", Settings.EMPTY, "type1", mapping);
createIndex("test", Settings.EMPTY, mapping);
ensureGreen();

client().prepareIndex("test").setId("0").setSource("field", "foo bar").setRefreshPolicy(IMMEDIATE).get();
Expand Down Expand Up @@ -96,7 +96,7 @@ public void testDocFreqs() throws IOException {
.endObject()
.endObject();
Settings settings = Settings.builder().put("number_of_shards", 1).build();
createIndex("test", settings, "_doc", mapping);
createIndex("test", settings, mapping);
ensureGreen();

int max = between(3, 10);
Expand Down Expand Up @@ -135,7 +135,7 @@ public void testWithIndexedPhrases() throws IOException {
.endObject()
.endObject();
Settings settings = Settings.builder().put("number_of_shards", 1).build();
createIndex("test", settings, "_doc", mapping);
createIndex("test", settings, mapping);
ensureGreen();

int max = between(3, 10);
Expand Down
Loading
Loading