Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of mapping types #119

Merged
merged 4 commits into from
Mar 29, 2022
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
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Build with Gradle
run: ./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT
run: ./gradlew build -Dopensearch.version=2.0.0-alpha1-SNAPSHOT
- name: Pull and Run Docker for security tests
run: |
version=2.0.0-SNAPSHOT
version=2.0.0-alpha1-SNAPSHOT
plugin_version=2.0.0.0-SNAPSHOT
pwd=`pwd`
echo $pwd
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Build with Gradle
run: ./gradlew.bat build -D"opensearch.version=2.0.0-SNAPSHOT" -x integTest -x jacocoTestReport
run: ./gradlew.bat build -D"opensearch.version=2.0.0-alpha1-SNAPSHOT" -x integTest -x jacocoTestReport
env:
_JAVA_OPTIONS: -Xmx4096M
- name: Create Artifact Path
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Build with Gradle
run: ./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT -x integTest -x jacocoTestReport
run: ./gradlew build -Dopensearch.version=2.0.0-alpha1-SNAPSHOT -x integTest -x jacocoTestReport
env:
_JAVA_OPTIONS: -Xmx4096M
- name: Create Artifact Path
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Run integration tests with multi node config
run: ./gradlew integTest -PnumNodes=5 -Dopensearch.version=2.0.0-SNAPSHOT
run: ./gradlew integTest -PnumNodes=5 -Dopensearch.version=2.0.0-alpha1-SNAPSHOT
- name: Run Backwards Compatibility Tests
run: |
echo "Running backwards compatibility tests ..."
Expand Down
23 changes: 12 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ buildscript {
distribution = 'oss-zip'
opensearch_group = "org.opensearch"
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT")
// 1.0.0 -> 1.0.0.0, and 1.0.0-SNAPSHOT -> 1.0.0.0-SNAPSHOT
opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT")
opendistro_plugin_version = System.getProperty("bwc.version", "1.13.0.1")
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
buildVersionQualifier = System.getProperty("build.version_qualifier")
// 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
}

repositories {
Expand Down Expand Up @@ -78,13 +85,7 @@ targetCompatibility = JavaVersion.VERSION_11

allprojects {
group 'org.opensearch'
version = opensearch_version.tokenize('-')[0] + '.0'
if (buildVersionQualifier) {
version += "-${buildVersionQualifier}"
}
if (isSnapshot) {
version += "-SNAPSHOT"
}
version = opensearch_build
}

dependencies {
Expand Down
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
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,13 @@ 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(
"book", "author", "type=keyword", "name", "type=text", "genre",
"type=keyword", "price", "type=float"));
.setMapping(
"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("name", "type=text", "genre", "type=keyword", "price", "type=float"));

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

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

indexRandom(true,
Expand Down Expand Up @@ -235,17 +234,15 @@ public void testIpRangeQuery() throws InterruptedException {

public void testHighlighterQuery() throws IOException, InterruptedException {
XContentBuilder mappings = jsonBuilder();
mappings.startObject();
mappings.startObject("type")
mappings.startObject()
.startObject("properties")
.startObject("text")
.field("type", "keyword")
.field("store", true)
.endObject()
.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("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("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("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("ip", "type=ip", "ips", "type=ip"));
waitForRelocation(ClusterHealthStatus.GREEN);

indexRandom(true,
Expand Down