Skip to content

Commit

Permalink
remove mapping type for async search index and in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
  • Loading branch information
eirsep committed Mar 29, 2022
1 parent 0be57c1 commit 6be4595
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public class AsynchronousSearchPersistenceService {

private static final Logger logger = LogManager.getLogger(AsynchronousSearchPersistenceService.class);
public static final String ASYNC_SEARCH_RESPONSE_INDEX = ".opendistro-asynchronous-search-response";
private static final String MAPPING_TYPE = "_doc";
/**
* The backoff policy to use when saving a asynchronous search response fails. The total wait
* time is 600000 milliseconds, ten minutes.
Expand Down Expand Up @@ -327,7 +326,7 @@ public void deleteExpiredResponses(ActionListener<AcknowledgedResponse> listener

private void createIndexAndDoStoreResult(String id, AsynchronousSearchPersistenceModel persistenceModel,
ActionListener<IndexResponse> listener) {
client.admin().indices().prepareCreate(ASYNC_SEARCH_RESPONSE_INDEX).addMapping(MAPPING_TYPE, mapping())
client.admin().indices().prepareCreate(ASYNC_SEARCH_RESPONSE_INDEX).setMapping(mapping())
.setSettings(indexSettings()).execute(ActionListener.wrap(createIndexResponse -> doStoreResult(id, persistenceModel,
listener), exception -> {
if (ExceptionsHelper.unwrapCause(exception) instanceof ResourceAlreadyExistsException) {
Expand Down Expand Up @@ -393,7 +392,7 @@ private Settings indexSettings() {
private XContentBuilder mapping() {
try {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject()
builder
.startObject("properties")
.startObject(START_TIME_MILLIS)
.field("type", "date")
Expand All @@ -409,7 +408,6 @@ private XContentBuilder mapping() {
.startObject(ERROR)
.field("type", "binary")
.endObject()
.endObject()
.endObject();
return builder;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

package org.opensearch.search.asynchronous.integTests;

import org.apache.lucene.tests.analysis.MockTokenizer;
import org.opensearch.search.asynchronous.plugin.AsynchronousSearchPlugin;
import org.opensearch.search.asynchronous.request.GetAsynchronousSearchRequest;
import org.opensearch.search.asynchronous.request.SubmitAsynchronousSearchRequest;
import org.opensearch.search.asynchronous.response.AsynchronousSearchResponse;
import org.opensearch.search.asynchronous.utils.TestClientUtils;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.pattern.PatternReplaceCharFilter;
import org.opensearch.action.admin.indices.refresh.RefreshRequest;
import org.opensearch.action.search.SearchRequest;
Expand Down Expand Up @@ -120,14 +120,14 @@ public void testAggregationQuery() throws InterruptedException, ExecutionExcepti
// statement
assertAcked(prepareCreate("test")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0))
.addMapping(
.setMapping(
"book", "author", "type=keyword", "name", "type=text", "genre",
"type=keyword", "price", "type=float"));
createIndex("idx_unmapped");
// idx_unmapped_author is same as main index but missing author field
assertAcked(prepareCreate("idx_unmapped_author")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0))
.addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float"));
.setMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float"));

ensureGreen();
String data[] = {
Expand Down Expand Up @@ -184,7 +184,7 @@ public void testAggregationQuery() throws InterruptedException, ExecutionExcepti

public void testIpRangeQuery() throws InterruptedException {
assertAcked(prepareCreate("idx")
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
.setMapping("type", "ip", "type=ip", "ips", "type=ip"));
waitForRelocation(ClusterHealthStatus.GREEN);

indexRandom(true,
Expand Down Expand Up @@ -245,7 +245,7 @@ public void testHighlighterQuery() throws IOException, InterruptedException {
.endObject().endObject();
mappings.endObject();
assertAcked(prepareCreate("test1")
.addMapping("type", mappings));
.setMapping(mappings));
client().prepareIndex("test1").setId("1")
.setSource(jsonBuilder().startObject().field("text", "foo").endObject())
.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected int numberOfShards() {

protected void createIdx(String keyFieldMapping) {
assertAcked(prepareCreate("idx")
.addMapping("type", "key", keyFieldMapping));
.setMapping("type", "key", keyFieldMapping));
}

protected void indexData() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testCleansUpExpiredAsynchronousSearchDuringFetchPhase() throws Excep
public void testDeletesExpiredAsynchronousSearchResponseFromPersistedStore() throws Exception {
String idx = "idx";
assertAcked(prepareCreate(idx)
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
.setMapping("type", "ip", "type=ip", "ips", "type=ip"));
waitForRelocation(ClusterHealthStatus.GREEN);
indexRandom(true,
client().prepareIndex(idx).setId("1").setSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected int maximumNumberOfReplicas() {
public void testRequestForwardingToCoordinatorNodeForPersistedAsynchronousSearch() throws Exception {
String idx = "idx";
assertAcked(prepareCreate(idx)
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
.setMapping("type", "ip", "type=ip", "ips", "type=ip"));
waitForRelocation(ClusterHealthStatus.GREEN);
indexRandom(true,
client().prepareIndex(idx).setId("1").setSource(
Expand Down Expand Up @@ -98,7 +98,7 @@ public void testRequestForwardingToCoordinatorNodeForRunningAsynchronousSearch()
List<ScriptedBlockPlugin> plugins = initBlockFactory();
String index = "idx";
assertAcked(prepareCreate(index)
.addMapping("type", "ip", "type=ip", "ips", "type=ip"));
.setMapping("type", "ip", "type=ip", "ips", "type=ip"));
waitForRelocation(ClusterHealthStatus.GREEN);

indexRandom(true,
Expand Down

0 comments on commit 6be4595

Please sign in to comment.