[Remove] Types from GET/MGET (#2168)

Removes type support from the get and mget transport and rest actions along
with removal from ShardGetService.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
Nick Knize 2022-02-21 11:37:27 -06:00 committed by GitHub
parent 5b3b98466a
commit 2e3f410957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
132 changed files with 534 additions and 1483 deletions

View File

@ -284,7 +284,7 @@ final class RequestConverters {
}
private static Request getStyleRequest(String method, GetRequest getRequest) {
Request request = new Request(method, endpoint(getRequest.index(), getRequest.type(), getRequest.id()));
Request request = new Request(method, endpoint(getRequest.index(), getRequest.id()));
Params parameters = new Params();
parameters.withPreference(getRequest.preference());
@ -315,13 +315,7 @@ final class RequestConverters {
parameters.withRealtime(getSourceRequest.realtime());
parameters.withFetchSourceContext(getSourceRequest.fetchSourceContext());
String optionalType = getSourceRequest.type();
String endpoint;
if (optionalType == null) {
endpoint = endpoint(getSourceRequest.index(), "_source", getSourceRequest.id());
} else {
endpoint = endpoint(getSourceRequest.index(), optionalType, getSourceRequest.id(), "_source");
}
String endpoint = endpoint(getSourceRequest.index(), "_source", getSourceRequest.id());
Request request = new Request(httpMethodName, endpoint);
request.addParameters(parameters.asMap());
return request;
@ -799,6 +793,10 @@ final class RequestConverters {
return new NByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));
}
static String endpoint(String index, String id) {
return new EndpointBuilder().addPathPart(index, MapperService.SINGLE_MAPPING_NAME, id).build();
}
@Deprecated
static String endpoint(String index, String type, String id) {
return new EndpointBuilder().addPathPart(index, type, id).build();

View File

@ -565,7 +565,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
int i = 1;
for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) {
assertThat(multiGetItemResponse.getIndex(), equalTo("test"));
assertThat(multiGetItemResponse.getType(), equalTo("_doc"));
assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++)));
}
}

View File

@ -70,7 +70,6 @@ import org.opensearch.index.VersionType;
import org.opensearch.index.get.GetResult;
import org.opensearch.rest.RestStatus;
import org.opensearch.rest.action.document.RestBulkAction;
import org.opensearch.rest.action.document.RestMultiGetAction;
import org.opensearch.script.Script;
import org.opensearch.script.ScriptType;
import org.opensearch.search.fetch.subphase.FetchSourceContext;
@ -337,7 +336,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
}
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertFalse(getResponse.isSourceEmpty());
@ -348,7 +346,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
GetRequest getRequest = new GetRequest("index", "does_not_exist");
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("does_not_exist", getResponse.getId());
assertFalse(getResponse.isExists());
assertEquals(-1, getResponse.getVersion());
@ -360,7 +357,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY));
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertTrue(getResponse.isSourceEmpty());
@ -376,7 +372,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
}
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertFalse(getResponse.isSourceEmpty());
@ -398,7 +393,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
assertTrue(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getResponse());
assertEquals("id1", response.getResponses()[0].getFailure().getId());
assertNull(response.getResponses()[0].getFailure().getType());
assertEquals("index", response.getResponses()[0].getFailure().getIndex());
assertEquals(
"OpenSearch exception [type=index_not_found_exception, reason=no such index [index]]",
@ -408,7 +402,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
assertTrue(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getResponse());
assertEquals("id2", response.getResponses()[1].getId());
assertNull(response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals(
"OpenSearch exception [type=index_not_found_exception, reason=no such index [index]]",
@ -434,14 +427,12 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
assertFalse(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getFailure());
assertEquals("id1", response.getResponses()[0].getId());
assertEquals("_doc", response.getResponses()[0].getType());
assertEquals("index", response.getResponses()[0].getIndex());
assertEquals(Collections.singletonMap("field", "value1"), response.getResponses()[0].getResponse().getSource());
assertFalse(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getFailure());
assertEquals("id2", response.getResponses()[1].getId());
assertEquals("_doc", response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals(Collections.singletonMap("field", "value2"), response.getResponses()[1].getResponse().getSource());
}
@ -456,25 +447,7 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
highLevelClient().bulk(bulk, expectWarningsOnce(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "id1");
multiGetRequest.add("index", "type", "id2");
MultiGetResponse response = execute(
multiGetRequest,
highLevelClient()::mget,
highLevelClient()::mgetAsync,
expectWarningsOnce(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE)
);
assertEquals(2, response.getResponses().length);
GetResponse firstResponse = response.getResponses()[0].getResponse();
assertEquals("index", firstResponse.getIndex());
assertEquals("type", firstResponse.getType());
assertEquals("id1", firstResponse.getId());
GetResponse secondResponse = response.getResponses()[1].getResponse();
assertEquals("index", secondResponse.getIndex());
assertEquals("type", secondResponse.getType());
assertEquals("id2", secondResponse.getId());
multiGetRequest.add("index", "id2");
}
public void testGetSource() throws IOException {
@ -509,7 +482,7 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
);
assertEquals(RestStatus.NOT_FOUND, exception.status());
assertEquals(
"OpenSearch exception [type=resource_not_found_exception, " + "reason=Document not found [index]/[_doc]/[does_not_exist]]",
"OpenSearch exception [type=resource_not_found_exception, " + "reason=Document not found [index]/[does_not_exist]]",
exception.getMessage()
);
}
@ -1077,7 +1050,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals(expectedIndex, getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id#1", getResponse.getId());
}
@ -1095,7 +1067,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals(docId, getResponse.getId());
}
@ -1119,7 +1090,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertEquals(routing, getResponse.getField("_routing").getValue());
}

View File

@ -172,10 +172,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
getAndExistsTest(RequestConverters::get, HttpGet.METHOD_NAME);
}
public void testGetWithType() {
getAndExistsWithTypeTest(RequestConverters::get, HttpGet.METHOD_NAME);
}
public void testSourceExists() throws IOException {
doTestSourceExists((index, id) -> new GetSourceRequest(index, id));
}
@ -221,13 +217,7 @@ public class RequestConvertersTests extends OpenSearchTestCase {
}
Request request = RequestConverters.sourceExists(getRequest);
assertEquals(HttpHead.METHOD_NAME, request.getMethod());
String type = getRequest.type();
if (type == null) {
assertEquals("/" + index + "/_source/" + id, request.getEndpoint());
} else {
assertEquals("/" + index + "/" + type + "/" + id + "/_source", request.getEndpoint());
}
assertEquals("/" + index + "/_source/" + id, request.getEndpoint());
assertEquals(expectedParams, request.getParameters());
assertNull(request.getEntity());
}
@ -321,7 +311,7 @@ public class RequestConvertersTests extends OpenSearchTestCase {
public void testMultiGetWithType() throws IOException {
MultiGetRequest multiGetRequest = new MultiGetRequest();
MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4));
MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4), randomAlphaOfLength(4));
multiGetRequest.add(item);
Request request = RequestConverters.multiGet(multiGetRequest);
@ -374,10 +364,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
getAndExistsTest(RequestConverters::exists, HttpHead.METHOD_NAME);
}
public void testExistsWithType() {
getAndExistsWithTypeTest(RequestConverters::exists, HttpHead.METHOD_NAME);
}
private static void getAndExistsTest(Function<GetRequest, Request> requestConverter, String method) {
String index = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
@ -435,18 +421,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
assertEquals(method, request.getMethod());
}
private static void getAndExistsWithTypeTest(Function<GetRequest, Request> requestConverter, String method) {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
GetRequest getRequest = new GetRequest(index, type, id);
Request request = requestConverter.apply(getRequest);
assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint());
assertNull(request.getEntity());
assertEquals(method, request.getMethod());
}
public void testReindex() throws IOException {
ReindexRequest reindexRequest = new ReindexRequest();
reindexRequest.setSourceIndices("source_idx");

View File

@ -2050,7 +2050,6 @@ public class CRUDDocumentationIT extends OpenSearchRestHighLevelClientTestCase {
assertThat(response.getResponses(), arrayWithSize(1));
MultiGetItemResponse item = response.getResponses()[0];
assertEquals("index", item.getIndex());
assertEquals("_doc", item.getType());
assertEquals("example_id", item.getId());
return item;
}

View File

@ -209,7 +209,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
)
);
Map<String, Object> source = client().prepareGet("index", "doc", "1").get().getSource();
Map<String, Object> source = client().prepareGet("index", "1").get().getSource();
assertThat(source.get("x"), equalTo(0));
assertThat(source.get("y"), equalTo(0));
}
@ -242,7 +242,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();
Map<String, Object> source = client().prepareGet("index", "doc", "1").get().getSource();
Map<String, Object> source = client().prepareGet("index", "1").get().getSource();
assertThat(source.get("x"), equalTo(0));
assertThat(source.get("y"), equalTo(0));
assertThat(source.get("z"), equalTo(0));
@ -260,7 +260,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();
source = client().prepareGet("index", "doc", "2").get().getSource();
source = client().prepareGet("index", "2").get().getSource();
assertThat(source.get("x"), equalTo(0));
assertThat(source.get("y"), equalTo(0));
assertThat(source.get("z"), equalTo(0));
@ -281,7 +281,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();
Map<String, Object> source = client().prepareGet("index", "doc", "1").get().getSource();
Map<String, Object> source = client().prepareGet("index", "1").get().getSource();
assertThat(source.get("x"), equalTo(0));
assertThat(source.get("y"), equalTo(0));
@ -294,7 +294,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();
source = client(ingestNode).prepareGet("index", "doc", "2").get().getSource();
source = client(ingestNode).prepareGet("index", "2").get().getSource();
assertThat(source.get("x"), equalTo(0));
assertThat(source.get("y"), equalTo(0));
}

View File

@ -32,7 +32,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -66,7 +65,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -97,7 +95,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -112,7 +109,7 @@ teardown:
- match: { error.root_cause.0.property_name: "field" }
---
"Test simulate without index type and id":
"Test simulate without id":
- do:
ingest.simulate:
body: >
@ -166,7 +163,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -190,7 +186,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -223,7 +218,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar"
@ -275,7 +269,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": {
@ -335,7 +328,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"not_foo": "bar"
@ -343,7 +335,6 @@ teardown:
},
{
"_index": "index",
"_type": "type",
"_id": "id2",
"_source": {
"foo": "bar"
@ -383,7 +374,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"foo": "bar",
@ -392,7 +382,6 @@ teardown:
},
{
"_index": "index",
"_type": "type",
"_id": "id2",
"_source": {
"foo": "5",
@ -525,7 +514,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"field1": "123.42 400 <foo>"
@ -602,7 +590,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"field1": "123.42 400 <foo>"
@ -655,7 +642,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"field1": "123.42 400 <foo>"
@ -729,7 +715,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"field1": "123.42 400 <foo>"
@ -804,7 +789,6 @@ teardown:
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "id",
"_source": {
"field1": "123.42 400 <foo>"

View File

@ -41,7 +41,6 @@ setup:
- do:
get:
index: test
type: _doc
id: 1
- is_true: found

View File

@ -501,13 +501,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
return rewritten;
}
}
GetRequest getRequest;
if (indexedDocumentType != null) {
deprecationLogger.deprecate("percolate_with_type", TYPE_DEPRECATION_MESSAGE);
getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentType, indexedDocumentId);
} else {
getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId);
}
GetRequest getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId);
getRequest.preference("_local");
getRequest.routing(indexedDocumentRouting);
getRequest.preference(indexedDocumentPreference);

View File

@ -184,7 +184,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
@Override
protected GetResponse executeGet(GetRequest getRequest) {
assertThat(getRequest.index(), Matchers.equalTo(indexedDocumentIndex));
assertThat(getRequest.type(), Matchers.equalTo(MapperService.SINGLE_MAPPING_NAME));
assertThat(getRequest.id(), Matchers.equalTo(indexedDocumentId));
assertThat(getRequest.routing(), Matchers.equalTo(indexedDocumentRouting));
assertThat(getRequest.preference(), Matchers.equalTo(indexedDocumentPreference));
@ -193,7 +192,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
return new GetResponse(
new GetResult(
indexedDocumentIndex,
MapperService.SINGLE_MAPPING_NAME,
indexedDocumentId,
0,
1,
@ -208,7 +206,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
return new GetResponse(
new GetResult(
indexedDocumentIndex,
MapperService.SINGLE_MAPPING_NAME,
indexedDocumentId,
UNASSIGNED_SEQ_NO,
0,
@ -341,7 +338,6 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
+ "\"}}"
);
rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext);
assertWarnings(PercolateQueryBuilder.TYPE_DEPRECATION_MESSAGE);
}
public void testBothDocumentAndDocumentsSpecified() {

View File

@ -130,7 +130,7 @@ public class ReindexVersioningTests extends ReindexTestCase {
client().prepareIndex("source", "_doc", "test").setVersionType(EXTERNAL).setVersion(SOURCE_VERSION).setSource("foo", "source")
);
assertEquals(SOURCE_VERSION, client().prepareGet("source", "_doc", "test").get().getVersion());
assertEquals(SOURCE_VERSION, client().prepareGet("source", "test").get().getVersion());
}
private void setupDest(int version) throws Exception {
@ -140,7 +140,7 @@ public class ReindexVersioningTests extends ReindexTestCase {
client().prepareIndex("dest", "_doc", "test").setVersionType(EXTERNAL).setVersion(version).setSource("foo", "dest")
);
assertEquals(version, client().prepareGet("dest", "_doc", "test").get().getVersion());
assertEquals(version, client().prepareGet("dest", "test").get().getVersion());
}
private void setupDestOlder() throws Exception {
@ -152,7 +152,7 @@ public class ReindexVersioningTests extends ReindexTestCase {
}
private void assertDest(String fooValue, int version) {
GetResponse get = client().prepareGet("dest", "_doc", "test").get();
GetResponse get = client().prepareGet("dest", "test").get();
assertEquals(fooValue, get.getSource().get("foo"));
assertEquals(version, get.getVersion());
}

View File

@ -56,35 +56,35 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
client().prepareIndex("test", "test", "4").setSource("foo", "c")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 4);
assertEquals(1, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(1, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(1, client().prepareGet("test", "1").get().getVersion());
assertEquals(1, client().prepareGet("test", "4").get().getVersion());
// Reindex all the docs
assertThat(updateByQuery().source("test").refresh(true).get(), matcher().updated(4));
assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(2, client().prepareGet("test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
// Now none of them
assertThat(updateByQuery().source("test").filter(termQuery("foo", "no_match")).refresh(true).get(), matcher().updated(0));
assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(2, client().prepareGet("test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
// Now half of them
assertThat(updateByQuery().source("test").filter(termQuery("foo", "a")).refresh(true).get(), matcher().updated(2));
assertEquals(3, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(3, client().prepareGet("test", "test", "2").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(3, client().prepareGet("test", "1").get().getVersion());
assertEquals(3, client().prepareGet("test", "2").get().getVersion());
assertEquals(2, client().prepareGet("test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
// Limit with size
UpdateByQueryRequestBuilder request = updateByQuery().source("test").size(3).refresh(true);
request.source().addSort("foo.keyword", SortOrder.ASC);
assertThat(request.get(), matcher().updated(3));
// Only the first three documents are updated because of sort
assertEquals(4, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(4, client().prepareGet("test", "test", "2").get().getVersion());
assertEquals(3, client().prepareGet("test", "test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(4, client().prepareGet("test", "1").get().getVersion());
assertEquals(4, client().prepareGet("test", "2").get().getVersion());
assertEquals(3, client().prepareGet("test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
}
public void testSlices() throws Exception {
@ -96,8 +96,8 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
client().prepareIndex("test", "test", "4").setSource("foo", "c")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 4);
assertEquals(1, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(1, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(1, client().prepareGet("test", "1").get().getVersion());
assertEquals(1, client().prepareGet("test", "4").get().getVersion());
int slices = randomSlices(2, 10);
int expectedSlices = expectedSliceStatuses(slices, "test");
@ -107,26 +107,26 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
updateByQuery().source("test").refresh(true).setSlices(slices).get(),
matcher().updated(4).slices(hasSize(expectedSlices))
);
assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(2, client().prepareGet("test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
// Now none of them
assertThat(
updateByQuery().source("test").filter(termQuery("foo", "no_match")).setSlices(slices).refresh(true).get(),
matcher().updated(0).slices(hasSize(expectedSlices))
);
assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(2, client().prepareGet("test", "1").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
// Now half of them
assertThat(
updateByQuery().source("test").filter(termQuery("foo", "a")).refresh(true).setSlices(slices).get(),
matcher().updated(2).slices(hasSize(expectedSlices))
);
assertEquals(3, client().prepareGet("test", "test", "1").get().getVersion());
assertEquals(3, client().prepareGet("test", "test", "2").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion());
assertEquals(3, client().prepareGet("test", "1").get().getVersion());
assertEquals(3, client().prepareGet("test", "2").get().getVersion());
assertEquals(2, client().prepareGet("test", "3").get().getVersion());
assertEquals(2, client().prepareGet("test", "4").get().getVersion());
}
public void testMultipleSources() throws Exception {
@ -159,7 +159,7 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
String index = entry.getKey();
List<IndexRequestBuilder> indexDocs = entry.getValue();
int randomDoc = between(0, indexDocs.size() - 1);
assertEquals(2, client().prepareGet(index, "test", Integer.toString(randomDoc)).get().getVersion());
assertEquals(2, client().prepareGet(index, Integer.toString(randomDoc)).get().getVersion());
}
}

View File

@ -76,7 +76,7 @@ public class UpdateByQueryWhileModifyingTests extends ReindexTestCase {
try {
for (int i = 0; i < MAX_MUTATIONS; i++) {
GetResponse get = client().prepareGet("test", "test", "test").get();
GetResponse get = client().prepareGet("test", "test").get();
assertEquals(value.get(), get.getSource().get("test"));
value.set(randomSimpleString(random()));
IndexRequestBuilder index = client().prepareIndex("test", "test", "test")
@ -106,7 +106,7 @@ public class UpdateByQueryWhileModifyingTests extends ReindexTestCase {
get.getVersion(),
attempts
);
get = client().prepareGet("test", "test", "test").get();
get = client().prepareGet("test", "test").get();
}
}
}

View File

@ -399,9 +399,9 @@
mget:
body:
docs:
- { _index: index2, _type: _doc, _id: en_123}
- { _index: index2, _type: _doc, _id: en_456}
- { _index: index2, _type: _doc, _id: fr_789}
- { _index: index2, _id: en_123}
- { _index: index2, _id: en_456}
- { _index: index2, _id: fr_789}
- is_true: docs.0.found
- match: { docs.0._index: index2 }

View File

@ -137,7 +137,7 @@ public class SizeMappingIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addMapping("type", "_size", "enabled=true"));
final String source = "{\"f\":10}";
indexRandom(true, client().prepareIndex("test", "type", "1").setSource(source, XContentType.JSON));
GetResponse getResponse = client().prepareGet("test", "type", "1").setStoredFields("_size").get();
GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get();
assertNotNull(getResponse.getField("_size"));
assertEquals(source.length(), (int) getResponse.getField("_size").getValue());
}

View File

@ -19,7 +19,6 @@
id: 1
- match: { _index: smb-test }
- match: { _type: _doc }
- match: { _id: "1"}
- match: { _version: 1}
- match: { _source: { foo: bar }}

View File

@ -46,8 +46,6 @@ import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.common.xcontent.support.XContentMapValues;
import org.opensearch.index.seqno.SeqNoStats;
import org.opensearch.rest.RestStatus;
import org.opensearch.rest.action.document.RestGetAction;
import org.opensearch.rest.action.document.RestIndexAction;
import org.opensearch.test.rest.OpenSearchRestTestCase;
import org.opensearch.test.rest.yaml.ObjectPath;
@ -365,7 +363,6 @@ public class IndexingIT extends OpenSearchRestTestCase {
private void assertVersion(final String index, final int docId, final String preference, final int expectedVersion) throws IOException {
Request request = new Request("GET", index + "/_doc/" + docId);
request.addParameter("preference", preference);
request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE));
final Response response = client().performRequest(request);
assertOK(response);

View File

@ -668,7 +668,6 @@ public class RecoveryIT extends AbstractRollingTestCase {
client().performRequest(new Request("POST", index + "/_refresh"));
for (int docId : updates.keySet()) {
Request get = new Request("GET", index + "/_doc/" + docId);
get.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE));
Map<String, Object> doc = entityAsMap(client().performRequest(get));
assertThat(XContentMapValues.extractValue("_source.updated_field", doc), equalTo(updates.get(docId)));
}

View File

@ -22,31 +22,6 @@
"description":"The name of the index"
}
}
},
{
"path":"/{index}/{type}/{id}",
"methods":[
"HEAD"
],
"parts":{
"id":{
"type":"string",
"description":"The document ID"
},
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document (use `_all` to fetch the first document matching the ID across all types)",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},

View File

@ -22,31 +22,6 @@
"description":"The name of the index"
}
}
},
{
"path":"/{index}/{type}/{id}",
"methods":[
"GET"
],
"parts":{
"id":{
"type":"string",
"description":"The document ID"
},
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document (use `_all` to fetch the first document matching the ID across all types)",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},

View File

@ -22,31 +22,6 @@
"description":"The name of the index"
}
}
},
{
"path":"/{index}/{type}/{id}/_source",
"methods":[
"GET"
],
"parts":{
"id":{
"type":"string",
"description":"The document ID"
},
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document; deprecated and optional starting with 7.0",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},

View File

@ -26,28 +26,6 @@
"description":"The name of the index"
}
}
},
{
"path":"/{index}/{type}/_mget",
"methods":[
"GET",
"POST"
],
"parts":{
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},
@ -86,7 +64,7 @@
}
},
"body":{
"description":"Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL.",
"description":"Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL.",
"required":true
}
}

View File

@ -17,6 +17,5 @@
id: 中文
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: 中文 }
- match: { _source: { foo: "Hello: 中文" } }

View File

@ -16,7 +16,6 @@
id: 1
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: '1' }
- match: { _source: { foo: "bar" } }

View File

@ -29,7 +29,6 @@
stored_fields: foo
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: '1' }
- match: { fields.foo: [bar] }
- is_false: _source

View File

@ -18,7 +18,6 @@
id: 1
- match: {_index: "test_1"}
- match: { _type: _doc }
- match: {_id: "1"}
- match: {_version: 1}
- match: {found: true}

View File

@ -23,7 +23,6 @@
get: { index: test_1, id: 1, _source: false }
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: "1" }
- is_false: _source
@ -62,7 +61,6 @@
_source: true
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { fields.count: [1] }
- match: { _source.include.field1: v1 }

View File

@ -12,7 +12,6 @@
body: { foo: bar }
- match: { _index: test-weird-index-中文 }
- match: { _type: _doc }
- match: { _id: "1"}
- match: { _version: 1}
@ -22,7 +21,6 @@
id: 1
- match: { _index: test-weird-index-中文 }
- match: { _type: _doc }
- match: { _id: "1"}
- match: { _version: 1}
- match: { _source: { foo: bar }}

View File

@ -12,7 +12,6 @@
- is_true: _id
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _version: 1 }
- set: { _id: id }
@ -22,7 +21,6 @@
id: '$id'
- match: { _index: test_1 }
- match: { _type: _doc }
- match: { _id: $id }
- match: { _version: 1 }
- match: { _source: { foo: bar }}

View File

@ -1,102 +0,0 @@
---
"Index with typeless API on an index that has types":
- skip:
version: " - 6.99.99"
reason: Typeless APIs were introduced in 7.0.0
- do:
indices.create: # not using include_type_name: false on purpose
include_type_name: true
index: index
body:
mappings:
not_doc:
properties:
foo:
type: "keyword"
- do:
index:
index: index
id: 1
body: { foo: bar }
- match: { _index: "index" }
- match: { _type: "_doc" }
- match: { _id: "1"}
- match: { _version: 1}
- do:
get: # not using typeless API on purpose
index: index
type: not_doc
id: 1
- match: { _index: "index" }
- match: { _type: "not_doc" } # the important bit to check
- match: { _id: "1"}
- match: { _version: 1}
- match: { _source: { foo: bar }}
- do:
index:
index: index
body: { foo: bar }
- match: { _index: "index" }
- match: { _type: "_doc" }
- match: { _version: 1}
- set: { _id: id }
- do:
get: # using typeful API on purpose
index: index
type: not_doc
id: '$id'
- match: { _index: "index" }
- match: { _type: "not_doc" } # the important bit to check
- match: { _id: $id}
- match: { _version: 1}
- match: { _source: { foo: bar }}
---
"Index call that introduces new field mappings":
- skip:
version: " - 6.99.99"
reason: Typeless APIs were introduced in 7.0.0
- do:
indices.create: # not using include_type_name: false on purpose
include_type_name: true
index: index
body:
mappings:
not_doc:
properties:
foo:
type: "keyword"
- do:
index:
index: index
id: 2
body: { new_field: value }
- match: { _index: "index" }
- match: { _type: "_doc" }
- match: { _id: "2" }
- match: { _version: 1 }
- do:
get: # using typeful API on purpose
index: index
type: not_doc
id: 2
- match: { _index: "index" }
- match: { _type: "not_doc" }
- match: { _id: "2" }
- match: { _version: 1}

View File

@ -66,7 +66,6 @@ setup:
id: "1"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { _source: { foo: "hello world" } }
@ -77,7 +76,6 @@ setup:
id: "2"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "2" }
- match: { _source: { foo: "hello world 2" } }
@ -88,7 +86,6 @@ setup:
id: "3"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "3" }
- match: { _source: { foo: "hello world 3" } }

View File

@ -40,7 +40,6 @@
id: "1"
- match: { _index: source }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { _source: { foo: "hello world" } }
@ -78,6 +77,5 @@
id: "1"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { _source: { foo: "hello world" } }

View File

@ -69,7 +69,6 @@ setup:
id: "1"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { _source: { foo: "hello world" } }
@ -80,7 +79,6 @@ setup:
id: "2"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "2" }
- match: { _source: { foo: "hello world 2" } }
@ -91,7 +89,6 @@ setup:
id: "3"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "3" }
- match: { _source: { foo: "hello world 3" } }
@ -162,7 +159,6 @@ setup:
id: "1"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "1" }
- match: { _source: { foo: "hello world" } }
@ -173,7 +169,6 @@ setup:
id: "2"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "2" }
- match: { _source: { foo: "hello world 2" } }
@ -184,7 +179,6 @@ setup:
id: "3"
- match: { _index: target }
- match: { _type: _doc }
- match: { _id: "3" }
- match: { _source: { foo: "hello world 3" } }

View File

@ -26,17 +26,14 @@
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: null }
- match: { docs.0._id: "1" }
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: _doc }
- match: { docs.1._id: "2" }
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: _doc }
- match: { docs.2._id: "1" }
- match: { docs.2._version: 1 }
- match: { docs.2._source: { foo: bar }}

View File

@ -18,7 +18,6 @@
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: null }
- match: { docs.0._id: "1" }
- do:
@ -29,5 +28,4 @@
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: _doc }
- match: { docs.0._id: "1" }

View File

@ -43,7 +43,6 @@
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: _doc }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}

View File

@ -34,12 +34,10 @@
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: _doc }
- match: { docs.0._id: "1" }
- is_false: docs.1.found
- match: { docs.1._index: test_two_and_three }
- match: { docs.1._type: null }
- match: { docs.1._id: "2" }
- match: { docs.1.error.root_cause.0.type: "illegal_argument_exception" }
- match: { docs.1.error.root_cause.0.reason: "/[aA]lias.\\[test_two_and_three\\].has.more.than.one.index.associated.with.it.\\[test_[23]{1},.test_[23]{1}\\],.can't.execute.a.single.index.op/" }

View File

@ -28,14 +28,12 @@
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: _doc }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: _doc }
- match: { docs.1._id: "3" }
- do:
@ -46,14 +44,12 @@
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: _doc }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_true: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: _doc }
- match: { docs.1._id: "2" }
- match: { docs.1._version: 1 }
- match: { docs.1._source: { foo: baz }}

View File

@ -24,17 +24,14 @@
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: null }
- match: { docs.0._id: "1" }
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: _doc }
- match: { docs.1._id: "2" }
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: _doc }
- match: { docs.2._id: "1" }
- match: { docs.2._version: 1 }
- match: { docs.2._source: { foo: bar }}

View File

@ -40,6 +40,5 @@
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: _doc }
- match: { docs.2._id: "1" }
- match: { docs.2._routing: "5" }

View File

@ -1,52 +0,0 @@
---
"Update result field":
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar }
doc_as_upsert: true
- match: { _version: 1 }
- match: { result: created }
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar }
doc_as_upsert: true
- match: { _version: 1 }
- match: { result: noop }
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar }
doc_as_upsert: true
detect_noop: false
- match: { _version: 2 }
- match: { result: updated }
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: baz }
doc_as_upsert: true
detect_noop: true
- match: { _version: 3 }
- match: { result: updated }

View File

@ -1,41 +0,0 @@
---
"Doc upsert":
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar, count: 1 }
upsert: { foo: baz }
- do:
get:
index: test_1
type: test
id: 1
- match: { _source.foo: baz }
- is_false: _source.count
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar, count: 1 }
upsert: { foo: baz }
- do:
get:
index: test_1
type: test
id: 1
- match: { _source.foo: bar }
- match: { _source.count: 1 }

View File

@ -1,41 +0,0 @@
---
"Doc as upsert":
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { foo: bar, count: 1 }
doc_as_upsert: true
- do:
get:
index: test_1
type: test
id: 1
- match: { _source.foo: bar }
- match: { _source.count: 1 }
- do:
update:
index: test_1
type: test
id: 1
body:
doc: { count: 2 }
doc_as_upsert: true
- do:
get:
index: test_1
type: test
id: 1
- match: { _source.foo: bar }
- match: { _source.count: 2 }

View File

@ -1,58 +0,0 @@
---
"Routing":
- do:
indices.create:
index: test_1
body:
settings:
index:
number_of_shards: 5
number_of_routing_shards: 5
number_of_replicas: 0
- do:
cluster.health:
wait_for_status: green
- do:
update:
index: test_1
type: test
id: 1
routing: 5
body:
doc: { foo: baz }
upsert: { foo: bar }
- do:
get:
index: test_1
type: test
id: 1
routing: 5
stored_fields: _routing
- match: { _routing: "5"}
- do:
catch: missing
update:
index: test_1
type: test
id: 1
body:
doc: { foo: baz }
- do:
update:
index: test_1
type: test
id: 1
routing: 5
_source: foo
body:
doc: { foo: baz }
- match: { get._source.foo: baz }

View File

@ -1,19 +0,0 @@
---
"Source filtering":
- do:
update:
index: test_1
type: test
id: 1
_source: [foo, bar]
body:
doc: { foo: baz }
upsert: { foo: bar }
- match: { get._source.foo: bar }
- is_false: get._source.bar
# TODO:
#
# - Add _routing

View File

@ -1,33 +0,0 @@
---
"Metadata Fields":
- skip:
version: "all"
reason: "Update doesn't return metadata fields, waiting for #3259"
- do:
indices.create:
index: test_1
- do:
update:
index: test_1
type: test
id: 1
parent: 5
fields: [ _routing ]
body:
doc: { foo: baz }
upsert: { foo: bar }
- match: { get._routing: "5" }
- do:
get:
index: test_1
type: test
id: 1
parent: 5
stored_fields: [ _routing ]

View File

@ -338,7 +338,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
String getShardAction = GetAction.NAME + "[s]";
interceptTransportActions(getShardAction);
GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "type", "id");
GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "id");
internalCluster().coordOnlyNodeClient().get(getRequest).actionGet();
clearInterceptedActions();
@ -394,7 +394,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
int numDocs = iterations(1, 30);
for (int i = 0; i < numDocs; i++) {
String indexOrAlias = randomIndexOrAlias();
multiGetRequest.add(indexOrAlias, "type", Integer.toString(i));
multiGetRequest.add(indexOrAlias, Integer.toString(i));
indices.add(indexOrAlias);
}
internalCluster().coordOnlyNodeClient().multiGet(multiGetRequest).actionGet();

View File

@ -229,7 +229,7 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
assertHitCount(client().prepareSearch("first_split").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs);
assertHitCount(client().prepareSearch("source").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs);
for (int i = 0; i < numDocs; i++) {
GetResponse getResponse = client().prepareGet("first_split", "t1", Integer.toString(i)).setRouting(routingValue[i]).get();
GetResponse getResponse = client().prepareGet("first_split", Integer.toString(i)).setRouting(routingValue[i]).get();
assertTrue(getResponse.isExists());
}
@ -274,7 +274,7 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
}
flushAndRefresh();
for (int i = 0; i < numDocs; i++) {
GetResponse getResponse = client().prepareGet("second_split", "t1", Integer.toString(i)).setRouting(routingValue[i]).get();
GetResponse getResponse = client().prepareGet("second_split", Integer.toString(i)).setRouting(routingValue[i]).get();
assertTrue(getResponse.isExists());
}
assertHitCount(client().prepareSearch("second_split").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs);

View File

@ -127,14 +127,14 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[0].getResponse().getShardId().getId(), equalTo(0));
assertThat(bulkResponse.getItems()[0].getResponse().getVersion(), equalTo(1L));
assertThat(bulkResponse.getItems()[0].getResponse().status(), equalTo(RestStatus.CREATED));
assertThat(client().prepareGet("index3", "type", "id").setRouting("1").get().getSource().get("foo"), equalTo("baz"));
assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("baz"));
bulkResponse = client().prepareBulk().add(client().prepareUpdate("alias1", "type", "id").setDoc("foo", "updated")).get();
assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures());
assertThat(client().prepareGet("index3", "type", "id").setRouting("1").get().getSource().get("foo"), equalTo("updated"));
assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("updated"));
bulkResponse = client().prepareBulk().add(client().prepareDelete("alias1", "type", "id")).get();
assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures());
assertFalse(client().prepareGet("index3", "type", "id").setRouting("1").get().isExists());
assertFalse(client().prepareGet("index3", "id").setRouting("1").get().isExists());
}
// allowing the auto-generated timestamp to externally be set would allow making the index inconsistent with duplicate docs

View File

@ -255,7 +255,7 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
processor.add(
new IndexRequest("test", "test", Integer.toString(testDocs)).source(Requests.INDEX_CONTENT_TYPE, "field", "value")
);
multiGetRequestBuilder.add("test", "test", Integer.toString(testDocs));
multiGetRequestBuilder.add("test", Integer.toString(testDocs));
} else {
testReadOnlyDocs++;
processor.add(
@ -320,7 +320,7 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
+ "\n";
processor.add(new BytesArray(source), null, null, XContentType.JSON);
}
multiGetRequestBuilder.add("test", "test", Integer.toString(i));
multiGetRequestBuilder.add("test", Integer.toString(i));
}
return multiGetRequestBuilder;
}
@ -345,7 +345,6 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
int i = 1;
for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) {
assertThat(multiGetItemResponse.getIndex(), equalTo("test"));
assertThat(multiGetItemResponse.getType(), equalTo("test"));
assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++)));
}
}

View File

@ -177,17 +177,17 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse().getId(), equalTo("3"));
assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(2L));
GetResponse getResponse = client().prepareGet().setIndex("test").setType("type1").setId("1").execute().actionGet();
GetResponse getResponse = client().prepareGet().setIndex("test").setId("1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(2L));
assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(2L));
getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").execute().actionGet();
getResponse = client().prepareGet().setIndex("test").setId("2").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(2L));
assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(3L));
getResponse = client().prepareGet().setIndex("test").setType("type1").setId("3").execute().actionGet();
getResponse = client().prepareGet().setIndex("test").setId("3").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(2L));
assertThat(getResponse.getSource().get("field1").toString(), equalTo("test"));
@ -217,15 +217,15 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse().getIndex(), equalTo("test"));
assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(3L));
getResponse = client().prepareGet().setIndex("test").setType("type1").setId("6").execute().actionGet();
getResponse = client().prepareGet().setIndex("test").setId("6").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(1L));
assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(0L));
getResponse = client().prepareGet().setIndex("test").setType("type1").setId("7").execute().actionGet();
getResponse = client().prepareGet().setIndex("test").setId("7").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(false));
getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").execute().actionGet();
getResponse = client().prepareGet().setIndex("test").setId("2").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(3L));
assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(4L));
@ -440,14 +440,13 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i)));
assertThat(response.getItems()[i].getVersion(), equalTo(1L));
assertThat(response.getItems()[i].getIndex(), equalTo("test"));
assertThat(response.getItems()[i].getType(), equalTo("type1"));
assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE));
assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i)));
assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(1L));
assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getGetResult().sourceAsMap().get("counter"), equalTo(1));
for (int j = 0; j < 5; j++) {
GetResponse getResponse = client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet();
GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getVersion(), equalTo(1L));
assertThat(((Number) getResponse.getSource().get("counter")).longValue(), equalTo(1L));
@ -480,7 +479,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i)));
assertThat(response.getItems()[i].getVersion(), equalTo(2L));
assertThat(response.getItems()[i].getIndex(), equalTo("test"));
assertThat(response.getItems()[i].getType(), equalTo("type1"));
assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE));
assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i)));
assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(2L));
@ -504,7 +502,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(id)));
assertThat(response.getItems()[i].getVersion(), equalTo(3L));
assertThat(response.getItems()[i].getIndex(), equalTo("test"));
assertThat(response.getItems()[i].getType(), equalTo("type1"));
assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE));
}
}
@ -526,7 +523,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(response.getItems()[i].getItemId(), equalTo(i));
assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i)));
assertThat(response.getItems()[i].getIndex(), equalTo("test"));
assertThat(response.getItems()[i].getType(), equalTo("type1"));
assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE));
}
@ -550,10 +546,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(itemResponse.getItemId(), equalTo(i));
assertThat(itemResponse.getId(), equalTo(Integer.toString(i)));
assertThat(itemResponse.getIndex(), equalTo("test"));
assertThat(itemResponse.getType(), equalTo("type1"));
assertThat(itemResponse.getOpType(), equalTo(OpType.UPDATE));
for (int j = 0; j < 5; j++) {
GetResponse getResponse = client().prepareGet("test", "type1", Integer.toString(i)).get();
GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).get();
assertThat(getResponse.isExists(), equalTo(false));
}
}

View File

@ -860,7 +860,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(1L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get();
client().prepareGet(indexOrAlias(), "1").setVersion(2).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
@ -883,7 +883,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(1L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get();
client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
@ -902,7 +902,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(2L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get();
client().prepareGet(indexOrAlias(), "1").setVersion(1).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
@ -925,7 +925,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(2L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get();
client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get();
fail();
} catch (VersionConflictEngineException e) {
// all good

View File

@ -115,25 +115,25 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
});
assertRequestBuilderThrows(
clientToMasterlessNode.prepareGet("test", "type1", "1"),
clientToMasterlessNode.prepareGet("test", "1"),
ClusterBlockException.class,
RestStatus.SERVICE_UNAVAILABLE
);
assertRequestBuilderThrows(
clientToMasterlessNode.prepareGet("no_index", "type1", "1"),
clientToMasterlessNode.prepareGet("no_index", "1"),
ClusterBlockException.class,
RestStatus.SERVICE_UNAVAILABLE
);
assertRequestBuilderThrows(
clientToMasterlessNode.prepareMultiGet().add("test", "type1", "1"),
clientToMasterlessNode.prepareMultiGet().add("test", "1"),
ClusterBlockException.class,
RestStatus.SERVICE_UNAVAILABLE
);
assertRequestBuilderThrows(
clientToMasterlessNode.prepareMultiGet().add("no_index", "type1", "1"),
clientToMasterlessNode.prepareMultiGet().add("no_index", "1"),
ClusterBlockException.class,
RestStatus.SERVICE_UNAVAILABLE
);
@ -275,7 +275,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
GetResponse getResponse = clientToMasterlessNode.prepareGet("test1", "type1", "1").get();
GetResponse getResponse = clientToMasterlessNode.prepareGet("test1", "1").get();
assertExists(getResponse);
SearchResponse countResponse = clientToMasterlessNode.prepareSearch("test1").setAllowPartialSearchResults(true).setSize(0).get();
@ -371,10 +371,10 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
}
});
GetResponse getResponse = client(randomFrom(nodesWithShards)).prepareGet("test1", "type1", "1").get();
GetResponse getResponse = client(randomFrom(nodesWithShards)).prepareGet("test1", "1").get();
assertExists(getResponse);
expectThrows(Exception.class, () -> client(partitionedNode).prepareGet("test1", "type1", "1").get());
expectThrows(Exception.class, () -> client(partitionedNode).prepareGet("test1", "1").get());
SearchResponse countResponse = client(randomFrom(nodesWithShards)).prepareSearch("test1")
.setAllowPartialSearchResults(true)

View File

@ -378,7 +378,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase {
final ActionFuture<IndexResponse> docIndexResponse = client().prepareIndex("index", "type", "1").setSource("field", 42).execute();
assertBusy(() -> assertTrue(client().prepareGet("index", "type", "1").get().isExists()));
assertBusy(() -> assertTrue(client().prepareGet("index", "1").get().isExists()));
// index another document, this time using dynamic mappings.
// The ack timeout of 0 on dynamic mapping updates makes it possible for the document to be indexed on the primary, even
@ -400,7 +400,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase {
assertNotNull(mapper.mappers().getMapper("field2"));
});
assertBusy(() -> assertTrue(client().prepareGet("index", "type", "2").get().isExists()));
assertBusy(() -> assertTrue(client().prepareGet("index", "2").get().isExists()));
// The mappings have not been propagated to the replica yet as a consequence the document count not be indexed
// We wait on purpose to make sure that the document is not indexed because the shard operation is stalled

View File

@ -439,7 +439,7 @@ public class UnsafeBootstrapAndDetachCommandIT extends OpenSearchIntegTestCase {
logger.info("--> verify 1 doc in the index");
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L);
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true));
logger.info("--> stop data-only node and detach it from the old cluster");
Settings dataNodeDataPathSettings = Settings.builder()
@ -474,7 +474,7 @@ public class UnsafeBootstrapAndDetachCommandIT extends OpenSearchIntegTestCase {
ensureGreen("test");
logger.info("--> verify the doc is there");
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true));
}
public void testNoInitialBootstrapAfterDetach() throws Exception {

View File

@ -255,7 +255,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
for (String id : ackedDocs.keySet()) {
assertTrue(
"doc [" + id + "] indexed via node [" + ackedDocs.get(id) + "] not found",
client(node).prepareGet("test", "type", id).setPreference("_local").get().isExists()
client(node).prepareGet("test", id).setPreference("_local").get().isExists()
);
}
} catch (AssertionError | NoShardAvailableActionException e) {
@ -316,7 +316,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
logger.info("Verifying if document exists via node[{}]", notIsolatedNode);
GetResponse getResponse = internalCluster().client(notIsolatedNode)
.prepareGet("test", "type", indexResponse.getId())
.prepareGet("test", indexResponse.getId())
.setPreference("_local")
.get();
assertThat(getResponse.isExists(), is(true));
@ -330,7 +330,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
for (String node : nodes) {
logger.info("Verifying if document exists after isolating node[{}] via node[{}]", isolatedNode, node);
getResponse = internalCluster().client(node).prepareGet("test", "type", indexResponse.getId()).setPreference("_local").get();
getResponse = internalCluster().client(node).prepareGet("test", indexResponse.getId()).setPreference("_local").get();
assertThat(getResponse.isExists(), is(true));
assertThat(getResponse.getVersion(), equalTo(1L));
assertThat(getResponse.getId(), equalTo(indexResponse.getId()));

View File

@ -117,18 +117,18 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
logger.info("Get [type1/1]");
for (int i = 0; i < 5; i++) {
getResult = client().prepareGet("test", "type1", "1").execute().actionGet();
getResult = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
assertThat("cycle(map) #" + i, (String) getResult.getSourceAsMap().get("name"), equalTo("test"));
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
}
logger.info("Get [type1/1] with script");
for (int i = 0; i < 5; i++) {
getResult = client().prepareGet("test", "type1", "1").setStoredFields("name").execute().actionGet();
getResult = client().prepareGet("test", "1").setStoredFields("name").execute().actionGet();
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
assertThat(getResult.isExists(), equalTo(true));
assertThat(getResult.getSourceAsBytes(), nullValue());
@ -137,7 +137,7 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
logger.info("Get [type1/2] (should be empty)");
for (int i = 0; i < 5; i++) {
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.isExists(), equalTo(false));
}
@ -151,7 +151,7 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
logger.info("Get [type1/1] (should be empty)");
for (int i = 0; i < 5; i++) {
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.isExists(), equalTo(false));
}
@ -169,10 +169,10 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
logger.info("Get [type1/1] and [type1/2]");
for (int i = 0; i < 5; i++) {
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
String ste1 = getResult.getSourceAsString();
String ste2 = Strings.toString(source("2", "test2"));
assertThat("cycle #" + i, ste1, equalTo(ste2));
@ -266,15 +266,15 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
for (int i = 0; i < 5; i++) {
GetResponse getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
GetResponse getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
assertThat("cycle #" + i, getResult.isExists(), equalTo(false));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("2", "test"))));
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
getResult = client().get(getRequest("test").type("type1").id(generatedId3)).actionGet();
getResult = client().get(getRequest("test").id(generatedId3)).actionGet();
assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("3", "test"))));
assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));

View File

@ -69,7 +69,7 @@ public class NodeRepurposeCommandIT extends OpenSearchIntegTestCase {
ensureGreen();
assertTrue(client().prepareGet(indexName, "type1", "1").get().isExists());
assertTrue(client().prepareGet(indexName, "1").get().isExists());
final Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode);
final Settings dataNodeDataPathSettings = internalCluster().dataPathSettings(dataNode);
@ -112,7 +112,7 @@ public class NodeRepurposeCommandIT extends OpenSearchIntegTestCase {
internalCluster().startCoordinatingOnlyNode(dataNodeDataPathSettings);
assertTrue(indexExists(indexName));
expectThrows(NoShardAvailableActionException.class, () -> client().prepareGet(indexName, "type1", "1").get());
expectThrows(NoShardAvailableActionException.class, () -> client().prepareGet(indexName, "1").get());
logger.info("--> Restarting and repurposing other node");

View File

@ -255,7 +255,6 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
assertThat(response.getId(), equalTo("1"));
assertThat(response.getGetResult(), notNullValue());
assertThat(response.getGetResult().getIndex(), equalTo("test"));
assertThat(response.getGetResult().getType(), equalTo("test"));
assertThat(response.getGetResult().getId(), equalTo("1"));
assertThat(response.getGetResult().getSource(), notNullValue());
assertThat((String) response.getGetResult().getSource().get("field1"), equalTo("value1"));

View File

@ -214,7 +214,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> trying to get the indexed document on the first index");
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
logger.info("--> closing test index...");
@ -255,7 +255,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> trying to get the indexed document on the first round (before close and shutdown)");
getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
logger.info("--> indexing a simple document");

View File

@ -90,25 +90,25 @@ public class GetActionIT extends OpenSearchIntegTestCase {
);
ensureGreen();
GetResponse response = client().prepareGet(indexOrAlias(), "type1", "1").get();
GetResponse response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(false));
logger.info("--> index doc 1");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
logger.info("--> non realtime get 1");
response = client().prepareGet(indexOrAlias(), "type1", "1").setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setRealtime(false).get();
assertThat(response.isExists(), equalTo(false));
logger.info("--> realtime get 1");
response = client().prepareGet(indexOrAlias(), "type1", "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1"));
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2"));
logger.info("--> realtime get 1 (no source, implicit)");
response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields(Strings.EMPTY_ARRAY).get();
response = client().prepareGet(indexOrAlias(), "1").setStoredFields(Strings.EMPTY_ARRAY).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
Set<String> fields = new HashSet<>(response.getFields().keySet());
@ -116,7 +116,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getSourceAsBytes(), nullValue());
logger.info("--> realtime get 1 (no source, explicit)");
response = client().prepareGet(indexOrAlias(), "type1", "1").setFetchSource(false).get();
response = client().prepareGet(indexOrAlias(), "1").setFetchSource(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
fields = new HashSet<>(response.getFields().keySet());
@ -124,14 +124,14 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getSourceAsBytes(), nullValue());
logger.info("--> realtime get 1 (no type)");
response = client().prepareGet(indexOrAlias(), null, "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1"));
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2"));
logger.info("--> realtime fetch of field");
response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").get();
response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsBytes(), nullValue());
@ -139,7 +139,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getField("field2"), nullValue());
logger.info("--> realtime fetch of field & source");
response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").setFetchSource("field1", null).get();
response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").setFetchSource("field1", null).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap(), hasKey("field1"));
@ -148,7 +148,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getField("field2"), nullValue());
logger.info("--> realtime get 1");
response = client().prepareGet(indexOrAlias(), "type1", "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1"));
@ -158,14 +158,14 @@ public class GetActionIT extends OpenSearchIntegTestCase {
refresh();
logger.info("--> non realtime get 1 (loaded from index)");
response = client().prepareGet(indexOrAlias(), "type1", "1").setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setRealtime(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1"));
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2"));
logger.info("--> realtime fetch of field (loaded from index)");
response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").get();
response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsBytes(), nullValue());
@ -173,7 +173,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getField("field2"), nullValue());
logger.info("--> realtime fetch of field & source (loaded from index)");
response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").setFetchSource(true).get();
response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").setFetchSource(true).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsBytes(), not(nullValue()));
@ -184,7 +184,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").get();
logger.info("--> realtime get 1");
response = client().prepareGet(indexOrAlias(), "type1", "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1_1"));
@ -193,7 +193,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
logger.info("--> update doc 1 again");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").get();
response = client().prepareGet(indexOrAlias(), "type1", "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1_2"));
@ -202,7 +202,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
response = client().prepareGet(indexOrAlias(), "type1", "1").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(false));
}
@ -222,7 +222,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
IllegalArgumentException exception = expectThrows(
IllegalArgumentException.class,
() -> client().prepareGet("alias1", "type", "_alias_id").get()
() -> client().prepareGet("alias1", "_alias_id").get()
);
assertThat(exception.getMessage(), endsWith("can't execute a single index op"));
}
@ -239,7 +239,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
);
ensureGreen();
MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "type1", "1").get();
MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "1").get();
assertThat(response.getResponses().length, equalTo(1));
assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false));
@ -248,11 +248,11 @@ public class GetActionIT extends OpenSearchIntegTestCase {
}
response = client().prepareMultiGet()
.add(indexOrAlias(), "type1", "1")
.add(indexOrAlias(), "type1", "15")
.add(indexOrAlias(), "type1", "3")
.add(indexOrAlias(), "type1", "9")
.add(indexOrAlias(), "type1", "11")
.add(indexOrAlias(), "1")
.add(indexOrAlias(), "15")
.add(indexOrAlias(), "3")
.add(indexOrAlias(), "9")
.add(indexOrAlias(), "11")
.get();
assertThat(response.getResponses().length, equalTo(5));
assertThat(response.getResponses()[0].getId(), equalTo("1"));
@ -278,8 +278,8 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// multi get with specific field
response = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").storedFields("field"))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "3").storedFields("field"))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").storedFields("field"))
.add(new MultiGetRequest.Item(indexOrAlias(), "3").storedFields("field"))
.get();
assertThat(response.getResponses().length, equalTo(2));
@ -304,16 +304,15 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addMapping("type1", mapping1, XContentType.JSON));
ensureGreen();
GetResponse response = client().prepareGet("test", "type1", "1").get();
GetResponse response = client().prepareGet("test", "1").get();
assertThat(response.isExists(), equalTo(false));
assertThat(response.isExists(), equalTo(false));
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().array("field", "1", "2").endObject()).get();
response = client().prepareGet("test", "type1", "1").setStoredFields("field").get();
response = client().prepareGet("test", "1").setStoredFields("field").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getType(), equalTo("type1"));
Set<String> fields = new HashSet<>(response.getFields().keySet());
assertThat(fields, equalTo(singleton("field")));
assertThat(response.getFields().get("field").getValues().size(), equalTo(2));
@ -322,7 +321,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// Now test values being fetched from stored fields.
refresh();
response = client().prepareGet("test", "type1", "1").setStoredFields("field").get();
response = client().prepareGet("test", "1").setStoredFields("field").get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
fields = new HashSet<>(response.getFields().keySet());
@ -336,7 +335,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(Settings.builder().put("index.refresh_interval", -1)));
ensureGreen();
GetResponse response = client().prepareGet("test", "type1", "1").get();
GetResponse response = client().prepareGet("test", "1").get();
assertThat(response.isExists(), equalTo(false));
logger.info("--> index doc 1");
@ -344,18 +343,18 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// From translog:
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getVersion(), equalTo(1L));
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(1).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getVersion(), equalTo(1L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get();
client().prepareGet(indexOrAlias(), "1").setVersion(2).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
@ -364,20 +363,20 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// From Lucene index:
refresh();
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getVersion(), equalTo(1L));
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getVersion(), equalTo(1L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get();
client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
@ -388,20 +387,20 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// From translog:
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getVersion(), equalTo(2L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get();
client().prepareGet(indexOrAlias(), "1").setVersion(1).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
}
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(2).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
@ -410,20 +409,20 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// From Lucene index:
refresh();
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
assertThat(response.getVersion(), equalTo(2L));
try {
client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get();
client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get();
fail();
} catch (VersionConflictEngineException e) {
// all good
}
response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get();
response = client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get();
assertThat(response.isExists(), equalTo(true));
assertThat(response.getId(), equalTo("1"));
assertThat(response.getIndex(), equalTo("test"));
@ -434,7 +433,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(Settings.builder().put("index.refresh_interval", -1)));
ensureGreen();
MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "type1", "1").get();
MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "1").get();
assertThat(response.getResponses().length, equalTo(1));
assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false));
@ -444,9 +443,9 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// Version from translog
response = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(2))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(2))
.get();
assertThat(response.getResponses().length, equalTo(3));
// [0] version doesn't matter, which is the default
@ -468,9 +467,9 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// Version from Lucene index
refresh();
response = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(2))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").version(2))
.setRealtime(false)
.get();
assertThat(response.getResponses().length, equalTo(3));
@ -494,9 +493,9 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// Version from translog
response = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(2))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(2))
.get();
assertThat(response.getResponses().length, equalTo(3));
// [0] version doesn't matter, which is the default
@ -518,9 +517,9 @@ public class GetActionIT extends OpenSearchIntegTestCase {
// Version from Lucene index
refresh();
response = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(2))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(Versions.MATCH_ANY))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(1))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").version(2))
.setRealtime(false)
.get();
assertThat(response.getResponses().length, equalTo(3));
@ -569,16 +568,13 @@ public class GetActionIT extends OpenSearchIntegTestCase {
IllegalArgumentException exc = expectThrows(
IllegalArgumentException.class,
() -> client().prepareGet(indexOrAlias(), "my-type1", "1").setStoredFields("field1").get()
() -> client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get()
);
assertThat(exc.getMessage(), equalTo("field [field1] isn't a leaf field"));
flush();
exc = expectThrows(
IllegalArgumentException.class,
() -> client().prepareGet(indexOrAlias(), "my-type1", "1").setStoredFields("field1").get()
);
exc = expectThrows(IllegalArgumentException.class, () -> client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get());
assertThat(exc.getMessage(), equalTo("field [field1] isn't a leaf field"));
}
@ -649,13 +645,13 @@ public class GetActionIT extends OpenSearchIntegTestCase {
logger.info("checking real time retrieval");
String field = "field1.field2.field3.field4";
GetResponse getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get();
GetResponse getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getField(field).getValues().size(), equalTo(2));
assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1"));
assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2"));
getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get();
getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getField(field).getValues().size(), equalTo(2));
assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1"));
@ -680,7 +676,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
logger.info("checking post-flush retrieval");
getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get();
getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getField(field).getValues().size(), equalTo(2));
assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1"));
@ -891,7 +887,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
}
private GetResponse multiGetDocument(String index, String type, String docId, String field, @Nullable String routing) {
MultiGetRequest.Item getItem = new MultiGetRequest.Item(index, type, docId).storedFields(field);
MultiGetRequest.Item getItem = new MultiGetRequest.Item(index, docId).storedFields(field);
if (routing != null) {
getItem.routing(routing);
}
@ -902,7 +898,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
}
private GetResponse getDocument(String index, String type, String docId, String field, @Nullable String routing) {
GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setType(type).setId(docId).setStoredFields(field);
GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setId(docId).setStoredFields(field);
if (routing != null) {
getRequestBuilder.setRouting(routing);
}

View File

@ -224,7 +224,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
final IndexResponse response = index.get();
assertThat(response.status(), equalTo(RestStatus.CREATED));
final GetRequestBuilder get = client().prepareGet("index", "_doc", "1");
final GetRequestBuilder get = client().prepareGet("index", "1");
final GetResponse getResponse = get.get();
assertTrue(getResponse.isExists());
final Map<String, Object> source = getResponse.getSourceAsMap();
@ -252,7 +252,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
final IndexResponse response = index.get();
assertThat(response.status(), equalTo(RestStatus.CREATED));
final GetRequestBuilder get = client().prepareGet("index", "_doc", "1");
final GetRequestBuilder get = client().prepareGet("index", "1");
final GetResponse getResponse = get.get();
assertTrue(getResponse.isExists());
final Map<String, Object> source = getResponse.getSourceAsMap();
@ -302,7 +302,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
final IndexResponse response = index.get();
assertThat(response.status(), equalTo(RestStatus.CREATED));
final GetRequestBuilder get = client().prepareGet("index", "_doc", "1");
final GetRequestBuilder get = client().prepareGet("index", "1");
final GetResponse getResponse = get.get();
assertTrue(getResponse.isExists());
final Map<String, Object> source = getResponse.getSourceAsMap();

View File

@ -139,7 +139,7 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
assertMappingsHaveField(mappings, "index", "type", "field" + i);
}
for (int i = 0; i < indexThreads.length; ++i) {
assertTrue(client().prepareGet("index", "type", Integer.toString(i)).get().isExists());
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
}
}

View File

@ -80,22 +80,22 @@ public class DateMathIndexExpressionsIntegrationIT extends OpenSearchIntegTestCa
assertHitCount(searchResponse, 3);
assertSearchHits(searchResponse, "1", "2", "3");
GetResponse getResponse = client().prepareGet(dateMathExp1, "type", "1").get();
GetResponse getResponse = client().prepareGet(dateMathExp1, "1").get();
assertThat(getResponse.isExists(), is(true));
assertThat(getResponse.getId(), equalTo("1"));
getResponse = client().prepareGet(dateMathExp2, "type", "2").get();
getResponse = client().prepareGet(dateMathExp2, "2").get();
assertThat(getResponse.isExists(), is(true));
assertThat(getResponse.getId(), equalTo("2"));
getResponse = client().prepareGet(dateMathExp3, "type", "3").get();
getResponse = client().prepareGet(dateMathExp3, "3").get();
assertThat(getResponse.isExists(), is(true));
assertThat(getResponse.getId(), equalTo("3"));
MultiGetResponse mgetResponse = client().prepareMultiGet()
.add(dateMathExp1, "type", "1")
.add(dateMathExp2, "type", "2")
.add(dateMathExp3, "type", "3")
.add(dateMathExp1, "1")
.add(dateMathExp2, "2")
.add(dateMathExp3, "3")
.get();
assertThat(mgetResponse.getResponses()[0].getResponse().isExists(), is(true));
assertThat(mgetResponse.getResponses()[0].getResponse().getId(), equalTo("1"));

View File

@ -694,7 +694,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
assertThat(stats.getTotal().getRefresh(), notNullValue());
// check get
GetResponse getResponse = client().prepareGet("test2", "type", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test2", "1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
stats = client().admin().indices().prepareStats().execute().actionGet();
@ -703,7 +703,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(0L));
// missing get
getResponse = client().prepareGet("test2", "type", "2").execute().actionGet();
getResponse = client().prepareGet("test2", "2").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(false));
stats = client().admin().indices().prepareStats().execute().actionGet();

View File

@ -227,10 +227,10 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
BulkResponse response = client().bulk(bulkRequest).actionGet();
assertThat(response.getItems().length, equalTo(bulkRequest.requests().size()));
Map<String, Object> inserted = client().prepareGet("index", "type", "1").get().getSourceAsMap();
Map<String, Object> inserted = client().prepareGet("index", "1").get().getSourceAsMap();
assertThat(inserted.get("field1"), equalTo("val1"));
assertThat(inserted.get("processed"), equalTo(true));
Map<String, Object> upserted = client().prepareGet("index", "type", "2").get().getSourceAsMap();
Map<String, Object> upserted = client().prepareGet("index", "2").get().getSourceAsMap();
assertThat(upserted.get("field1"), equalTo("upserted_val"));
assertThat(upserted.get("processed"), equalTo(true));
}
@ -258,14 +258,14 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
client().prepareIndex("test", "type", "1").setPipeline("_id").setSource("field", "value", "fail", false).get();
Map<String, Object> doc = client().prepareGet("test", "type", "1").get().getSourceAsMap();
Map<String, Object> doc = client().prepareGet("test", "1").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value"));
assertThat(doc.get("processed"), equalTo(true));
client().prepareBulk()
.add(client().prepareIndex("test", "type", "2").setSource("field", "value2", "fail", false).setPipeline("_id"))
.get();
doc = client().prepareGet("test", "type", "2").get().getSourceAsMap();
doc = client().prepareGet("test", "2").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value2"));
assertThat(doc.get("processed"), equalTo(true));
@ -452,7 +452,7 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
}
client().prepareIndex("test", "_doc").setId("1").setSource("{}", XContentType.JSON).setPipeline("1").get();
Map<String, Object> inserted = client().prepareGet("test", "_doc", "1").get().getSourceAsMap();
Map<String, Object> inserted = client().prepareGet("test", "1").get().getSourceAsMap();
assertThat(inserted.get("readme"), equalTo("pipeline with id [3] is a bad pipeline"));
}

View File

@ -68,8 +68,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
.get();
MultiGetResponse mgetResponse = client().prepareMultiGet()
.add(new MultiGetRequest.Item("test", "test", "1"))
.add(new MultiGetRequest.Item("nonExistingIndex", "test", "1"))
.add(new MultiGetRequest.Item("test", "1"))
.add(new MultiGetRequest.Item("nonExistingIndex", "1"))
.get();
assertThat(mgetResponse.getResponses().length, is(2));
@ -84,7 +84,7 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
is("nonExistingIndex")
);
mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("nonExistingIndex", "test", "1")).get();
mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("nonExistingIndex", "1")).get();
assertThat(mgetResponse.getResponses().length, is(1));
assertThat(mgetResponse.getResponses()[0].getIndex(), is("nonExistingIndex"));
assertThat(mgetResponse.getResponses()[0].isFailed(), is(true));
@ -105,8 +105,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
.get();
MultiGetResponse mgetResponse = client().prepareMultiGet()
.add(new MultiGetRequest.Item("test", "test", "1"))
.add(new MultiGetRequest.Item("multiIndexAlias", "test", "1"))
.add(new MultiGetRequest.Item("test", "1"))
.add(new MultiGetRequest.Item("multiIndexAlias", "1"))
.get();
assertThat(mgetResponse.getResponses().length, is(2));
@ -117,7 +117,7 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
assertThat(mgetResponse.getResponses()[1].isFailed(), is(true));
assertThat(mgetResponse.getResponses()[1].getFailure().getMessage(), containsString("more than one index"));
mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("multiIndexAlias", "test", "1")).get();
mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("multiIndexAlias", "1")).get();
assertThat(mgetResponse.getResponses().length, is(1));
assertThat(mgetResponse.getResponses()[0].getIndex(), is("multiIndexAlias"));
assertThat(mgetResponse.getResponses()[0].isFailed(), is(true));
@ -144,7 +144,7 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
.setRefreshPolicy(IMMEDIATE)
.get();
MultiGetResponse mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("alias1", "test", "1")).get();
MultiGetResponse mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("alias1", "1")).get();
assertEquals(1, mgetResponse.getResponses().length);
assertEquals("test", mgetResponse.getResponses()[0].getIndex());
@ -172,13 +172,13 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
for (int i = 0; i < 100; i++) {
if (i % 2 == 0) {
request.add(
new MultiGetRequest.Item(indexOrAlias(), "type", Integer.toString(i)).fetchSourceContext(
new MultiGetRequest.Item(indexOrAlias(), Integer.toString(i)).fetchSourceContext(
new FetchSourceContext(true, new String[] { "included" }, new String[] { "*.hidden_field" })
)
);
} else {
request.add(
new MultiGetRequest.Item(indexOrAlias(), "type", Integer.toString(i)).fetchSourceContext(new FetchSourceContext(false))
new MultiGetRequest.Item(indexOrAlias(), Integer.toString(i)).fetchSourceContext(new FetchSourceContext(false))
);
}
}
@ -219,8 +219,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
.get();
MultiGetResponse mgetResponse = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "test", id).routing(routingOtherShard))
.add(new MultiGetRequest.Item(indexOrAlias(), "test", id))
.add(new MultiGetRequest.Item(indexOrAlias(), id).routing(routingOtherShard))
.add(new MultiGetRequest.Item(indexOrAlias(), id))
.get();
assertThat(mgetResponse.getResponses().length, is(2));

View File

@ -419,7 +419,7 @@ public class RecoveryWhileUnderLoadIT extends OpenSearchIntegTestCase {
ShardId docShard = clusterService.operationRouting().shardId(state, "test", id, null);
if (docShard.id() == shard) {
for (ShardRouting shardRouting : state.routingTable().shardRoutingTable("test", shard)) {
GetResponse response = client().prepareGet("test", "type", id)
GetResponse response = client().prepareGet("test", id)
.setPreference("_only_nodes:" + shardRouting.currentNodeId())
.get();
if (response.isExists()) {

View File

@ -86,13 +86,13 @@ public class SimpleRecoveryIT extends OpenSearchIntegTestCase {
GetResponse getResult;
for (int i = 0; i < 5; i++) {
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
}
@ -103,17 +103,17 @@ public class SimpleRecoveryIT extends OpenSearchIntegTestCase {
ensureGreen();
for (int i = 0; i < 5; i++) {
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
getResult = client().get(getRequest("test").id("1")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
getResult = client().get(getRequest("test").type("type1").id("2")).actionGet();
getResult = client().get(getRequest("test").id("2")).actionGet();
assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
}
}

View File

@ -66,16 +66,16 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> verifying get with routing alias, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> updating with id [1] and routing through alias");
@ -85,9 +85,9 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
.execute()
.actionGet();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(
client().prepareGet("alias0", "type1", "1").execute().actionGet().getSourceAsMap().get("field").toString(),
client().prepareGet("alias0", "1").execute().actionGet().getSourceAsMap().get("field").toString(),
equalTo("value2")
);
}
@ -95,29 +95,29 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> deleting with no routing, should not delete anything");
client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> deleting with routing alias, should delete");
client().prepareDelete("alias0", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> indexing with id [1], and routing [0] using alias");
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true));
}
}
@ -137,11 +137,11 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> search with no routing, should fine one");
@ -494,22 +494,22 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
client().prepareIndex("alias-a0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test-a", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("alias-a0", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias-a0", "1").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> indexing with id [0], and routing [1] using alias to test-b");
client().prepareIndex("alias-b1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test-a", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("alias-b1", "type1", "1").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("alias-b1", "1").execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> search with alias-a1,alias-b0, should not find");
@ -655,7 +655,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> verifying get and search with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true));
assertThat(
client().prepareSearch("alias")
.setQuery(QueryBuilders.matchAllQuery())
@ -717,8 +717,8 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> verifying get and search with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "type1", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true));
assertThat(
client().prepareSearch("alias")
.setQuery(QueryBuilders.matchAllQuery())

View File

@ -231,7 +231,7 @@ public class PartitionedRoutingIT extends OpenSearchIntegTestCase {
String routing = routingEntry.getKey();
for (String id : routingEntry.getValue()) {
assertTrue(client().prepareGet(index, "type", id).setRouting(routing).execute().actionGet().isExists());
assertTrue(client().prepareGet(index, id).setRouting(routing).execute().actionGet().isExists());
}
}
}

View File

@ -100,25 +100,25 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
.get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> deleting with no routing, should not delete anything");
client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> deleting with routing, should delete");
client().prepareDelete("test", "type1", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> indexing with id [1], and routing [0]");
@ -129,11 +129,11 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
.get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
}
@ -150,11 +150,11 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
.get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
}
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> search with no routing, should fine one");
@ -381,10 +381,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> verifying get with routing, should find");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(),
equalTo(true)
);
assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> deleting with no routing, should fail");
@ -397,16 +394,13 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
for (int i = 0; i < 5; i++) {
try {
client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists();
client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists();
fail("get with missing routing when routing is required should fail");
} catch (RoutingMissingException e) {
assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
assertThat(
client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(),
equalTo(true)
);
assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
try {
@ -427,13 +421,13 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
for (int i = 0; i < 5; i++) {
try {
client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists();
client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists();
fail();
} catch (RoutingMissingException e) {
assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
GetResponse getResponse = client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet();
GetResponse getResponse = client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getSourceAsMap().get("field"), equalTo("value2"));
}
@ -442,16 +436,13 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
for (int i = 0; i < 5; i++) {
try {
client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists();
client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists();
fail();
} catch (RoutingMissingException e) {
assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
assertThat(
client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(),
equalTo(false)
);
assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false));
}
}
@ -487,7 +478,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST));
assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]"));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]"));
}
}
@ -518,7 +509,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.UPDATE));
assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST));
assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]"));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]"));
}
}
@ -543,7 +534,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.DELETE));
assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST));
assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]"));
assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]"));
}
}
@ -588,17 +579,14 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
.get();
logger.info("--> verifying get with id [1] with routing [0], should succeed");
assertThat(
client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(),
equalTo(true)
);
assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
logger.info("--> verifying get with id [1], with no routing, should fail");
try {
client().prepareGet(indexOrAlias(), "type1", "1").get();
client().prepareGet(indexOrAlias(), "1").get();
fail();
} catch (RoutingMissingException e) {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
logger.info("--> verifying explain with id [2], with routing [0], should succeed");
@ -614,7 +602,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
client().prepareExplain(indexOrAlias(), "type1", "2").setQuery(QueryBuilders.matchAllQuery()).get();
fail();
} catch (RoutingMissingException e) {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[2]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[2]"));
}
logger.info("--> verifying term vector with id [1], with routing [0], should succeed");
@ -626,7 +614,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
client().prepareTermVectors(indexOrAlias(), "1").get();
fail();
} catch (RoutingMissingException e) {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[_doc]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
@ -640,13 +628,13 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
client().prepareUpdate(indexOrAlias(), "type1", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get();
fail();
} catch (RoutingMissingException e) {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
logger.info("--> verifying mget with ids [1,2], with routing [0], should succeed");
MultiGetResponse multiGetResponse = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").routing("0"))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").routing("0"))
.add(new MultiGetRequest.Item(indexOrAlias(), "1").routing("0"))
.add(new MultiGetRequest.Item(indexOrAlias(), "2").routing("0"))
.get();
assertThat(multiGetResponse.getResponses().length, equalTo(2));
assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(false));
@ -656,16 +644,16 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> verifying mget with ids [1,2], with no routing, should fail");
multiGetResponse = client().prepareMultiGet()
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1"))
.add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2"))
.add(new MultiGetRequest.Item(indexOrAlias(), "1"))
.add(new MultiGetRequest.Item(indexOrAlias(), "2"))
.get();
assertThat(multiGetResponse.getResponses().length, equalTo(2));
assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(true));
assertThat(multiGetResponse.getResponses()[0].getFailure().getId(), equalTo("1"));
assertThat(multiGetResponse.getResponses()[0].getFailure().getMessage(), equalTo("routing is required for [test]/[type1]/[1]"));
assertThat(multiGetResponse.getResponses()[0].getFailure().getMessage(), equalTo("routing is required for [test]/[1]"));
assertThat(multiGetResponse.getResponses()[1].isFailed(), equalTo(true));
assertThat(multiGetResponse.getResponses()[1].getFailure().getId(), equalTo("2"));
assertThat(multiGetResponse.getResponses()[1].getFailure().getMessage(), equalTo("routing is required for [test]/[type1]/[2]"));
assertThat(multiGetResponse.getResponses()[1].getFailure().getMessage(), equalTo("routing is required for [test]/[2]"));
MultiTermVectorsResponse multiTermVectorsResponse = client().prepareMultiTermVectors()
.add(new TermVectorsRequest(indexOrAlias(), "1").routing(routingValue))
@ -690,7 +678,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(multiTermVectorsResponse.getResponses()[0].isFailed(), equalTo(true));
assertThat(
multiTermVectorsResponse.getResponses()[0].getFailure().getCause().getMessage(),
equalTo("routing is required for [test]/[_doc]/[1]")
equalTo("routing is required for [test]/[1]")
);
assertThat(multiTermVectorsResponse.getResponses()[0].getResponse(), nullValue());
assertThat(multiTermVectorsResponse.getResponses()[1].getId(), equalTo("2"));
@ -698,7 +686,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(multiTermVectorsResponse.getResponses()[1].getResponse(), nullValue());
assertThat(
multiTermVectorsResponse.getResponses()[1].getFailure().getCause().getMessage(),
equalTo("routing is required for [test]/[_doc]/[2]")
equalTo("routing is required for [test]/[2]")
);
}

View File

@ -922,7 +922,7 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
Throwable cause = exception.getCause();
assertThat(cause, instanceOf(RoutingMissingException.class));
assertThat(cause.getMessage(), equalTo("routing is required for [test]/[_doc]/[1]"));
assertThat(cause.getMessage(), equalTo("routing is required for [test]/[1]"));
}
{
@ -941,7 +941,7 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
Throwable cause = exception.getCause();
assertThat(cause, instanceOf(RoutingMissingException.class));
assertThat(cause.getMessage(), equalTo("routing is required for [test]/[_doc]/[2]"));
assertThat(cause.getMessage(), equalTo("routing is required for [test]/[2]"));
}
}
}

View File

@ -101,7 +101,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
.get();
waitForRelocation(ClusterHealthStatus.GREEN);
GetResponse getResponse = client().prepareGet("test", "type1", "1").get();
GetResponse getResponse = client().prepareGet("test", "1").get();
assertThat(getResponse.isExists(), equalTo(true));
assertThat(getResponse.getSourceAsBytes(), notNullValue());
refresh();
@ -263,7 +263,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
)
.get();
GetResponse getResponse = client().prepareGet("test", "type1", "1").get();
GetResponse getResponse = client().prepareGet("test", "1").get();
assertThat(getResponse.isExists(), equalTo(true));
waitForRelocation(ClusterHealthStatus.GREEN);
refresh();

View File

@ -590,7 +590,7 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("locations").setSettings(settings).addMapping("location", mapping));
client().prepareIndex("locations", "location", "1").setCreate(true).setSource(source).get();
refresh();
client().prepareGet("locations", "location", "1").get();
client().prepareGet("locations", "1").get();
SearchResponse result = client().prepareSearch("locations")
.setQuery(QueryBuilders.matchAllQuery())

View File

@ -147,8 +147,8 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase {
assertThat(restoreSnapshotResponse1.status(), equalTo(RestStatus.ACCEPTED));
assertThat(restoreSnapshotResponse2.status(), equalTo(RestStatus.ACCEPTED));
ensureGreen(restoredIndexName1, restoredIndexName2);
assertThat(client.prepareGet(restoredIndexName1, "_doc", docId).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName2, "_doc", docId2).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName1, docId).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName2, docId2).get().isExists(), equalTo(true));
}
public void testParallelRestoreOperationsFromSingleSnapshot() throws Exception {
@ -206,8 +206,8 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase {
assertThat(restoreSnapshotResponse1.get().status(), equalTo(RestStatus.ACCEPTED));
assertThat(restoreSnapshotResponse2.get().status(), equalTo(RestStatus.ACCEPTED));
ensureGreen(restoredIndexName1, restoredIndexName2);
assertThat(client.prepareGet(restoredIndexName1, "_doc", docId).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName2, "_doc", sameSourceIndex ? docId : docId2).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName1, docId).get().isExists(), equalTo(true));
assertThat(client.prepareGet(restoredIndexName2, sameSourceIndex ? docId : docId2).get().isExists(), equalTo(true));
}
public void testRestoreIncreasesPrimaryTerms() {

View File

@ -73,6 +73,7 @@ import org.opensearch.index.Index;
import org.opensearch.index.IndexService;
import org.opensearch.index.engine.Engine;
import org.opensearch.index.engine.EngineTestCase;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.shard.IndexShard;
import org.opensearch.index.shard.ShardId;
import org.opensearch.indices.IndicesService;
@ -288,12 +289,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
Path absolutePath = randomRepoPath().toAbsolutePath();
logger.info("Path [{}]", absolutePath);
String restoredIndexName = indexName + "-restored";
String typeName = "actions";
String expectedValue = "expected";
// Write a document
String docId = Integer.toString(randomInt());
index(indexName, typeName, docId, "value", expectedValue);
index(indexName, MapperService.SINGLE_MAPPING_NAME, docId, "value", expectedValue);
createRepository(repoName, "fs", absolutePath);
createSnapshot(repoName, snapshotName, Collections.singletonList(indexName));
@ -305,7 +305,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
.get();
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
assertThat(client().prepareGet(restoredIndexName, typeName, docId).get().isExists(), equalTo(true));
assertThat(client().prepareGet(restoredIndexName, docId).get().isExists(), equalTo(true));
}
public void testFreshIndexUUID() {

View File

@ -176,7 +176,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("1"));
}
@ -189,7 +189,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("2"));
}
}
@ -219,7 +219,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("balance").toString(), equalTo("9"));
}
@ -234,7 +234,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("balance").toString(), equalTo("7"));
}
}
@ -339,7 +339,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("2"));
}
@ -355,7 +355,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("5"));
}
@ -376,7 +376,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("5"));
}
@ -397,7 +397,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getIndex(), equalTo("test"));
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(false));
}
@ -423,7 +423,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
.execute()
.actionGet();
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("1"));
assertThat(getResponse.getSourceAsMap().get("field2").toString(), equalTo("2"));
}
@ -434,7 +434,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
.execute()
.actionGet();
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("3"));
assertThat(getResponse.getSourceAsMap().get("field2").toString(), equalTo("2"));
}
@ -455,7 +455,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
.execute()
.actionGet();
for (int i = 0; i < 5; i++) {
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet();
Map map1 = (Map) getResponse.getSourceAsMap().get("map");
assertThat(map1.size(), equalTo(3));
assertThat(map1.containsKey("map1"), equalTo(true));
@ -575,10 +575,9 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertEquals(2, updateResponse.getVersion());
GetResponse getResponse = client().prepareGet("test", "type1", "id1").setRouting("routing1").execute().actionGet();
GetResponse getResponse = client().prepareGet("test", "id1").setRouting("routing1").execute().actionGet();
Map<String, Object> updateContext = (Map<String, Object>) getResponse.getSourceAsMap().get("update_context");
assertEquals("test", updateContext.get("_index"));
assertEquals("type1", updateContext.get("_type"));
assertEquals("id1", updateContext.get("_id"));
assertEquals(1, updateContext.get("_version"));
assertEquals("routing1", updateContext.get("_routing"));
@ -591,10 +590,9 @@ public class UpdateIT extends OpenSearchIntegTestCase {
assertEquals(2, updateResponse.getVersion());
getResponse = client().prepareGet("test", "type1", "id2").execute().actionGet();
getResponse = client().prepareGet("test", "id2").execute().actionGet();
updateContext = (Map<String, Object>) getResponse.getSourceAsMap().get("update_context");
assertEquals("test", updateContext.get("_index"));
assertEquals("type1", updateContext.get("_type"));
assertEquals("id2", updateContext.get("_id"));
assertEquals(1, updateContext.get("_version"));
assertNull(updateContext.get("_routing"));
@ -675,7 +673,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
}
assertThat(failures.size(), equalTo(0));
for (int i = 0; i < numberOfUpdatesPerThread; i++) {
GetResponse response = client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet();
GetResponse response = client().prepareGet("test", Integer.toString(i)).execute().actionGet();
assertThat(response.getId(), equalTo(Integer.toString(i)));
assertThat(response.isExists(), equalTo(true));
assertThat(response.getVersion(), equalTo((long) numberOfThreads));
@ -892,7 +890,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numberOfIdsPerThread; ++i) {
int totalFailures = 0;
GetResponse response = client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet();
GetResponse response = client().prepareGet("test", Integer.toString(i)).execute().actionGet();
if (response.isExists()) {
assertThat(response.getId(), equalTo(Integer.toString(i)));
int expectedVersion = (numberOfThreads * numberOfUpdatesPerId * 2) + 1;

View File

@ -77,9 +77,9 @@ public class ConcurrentDocumentOperationIT extends OpenSearchIntegTestCase {
client().admin().indices().prepareRefresh().execute().actionGet();
logger.info("done indexing, check all have the same field value");
Map masterSource = client().prepareGet("test", "type1", "1").execute().actionGet().getSourceAsMap();
Map masterSource = client().prepareGet("test", "1").execute().actionGet().getSourceAsMap();
for (int i = 0; i < (cluster().size() * 5); i++) {
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().getSourceAsMap(), equalTo(masterSource));
assertThat(client().prepareGet("test", "1").execute().actionGet().getSourceAsMap(), equalTo(masterSource));
}
}
}

View File

@ -135,7 +135,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
refresh();
}
for (int i = 0; i < 10; i++) {
assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(14L));
assertThat(client().prepareGet("test", "1").get().getVersion(), equalTo(14L));
}
// deleting with a lower version fails.
@ -203,7 +203,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
refresh();
}
for (int i = 0; i < 10; i++) {
assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(14L));
assertThat(client().prepareGet("test", "1").execute().actionGet().getVersion(), equalTo(14L));
}
// deleting with a lower version fails.
@ -349,7 +349,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
client().admin().indices().prepareRefresh().execute().actionGet();
for (int i = 0; i < 10; i++) {
final GetResponse response = client().prepareGet("test", "type", "1").get();
final GetResponse response = client().prepareGet("test", "1").get();
assertThat(response.getSeqNo(), equalTo(1L));
assertThat(response.getPrimaryTerm(), equalTo(1L));
}
@ -420,7 +420,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
);
for (int i = 0; i < 10; i++) {
assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2L));
assertThat(client().prepareGet("test", "1").execute().actionGet().getVersion(), equalTo(2L));
}
client().admin().indices().prepareRefresh().execute().actionGet();
@ -787,7 +787,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
} else {
expected = -1;
}
long actualVersion = client().prepareGet("test", "type", id).execute().actionGet().getVersion();
long actualVersion = client().prepareGet("test", id).execute().actionGet().getVersion();
if (actualVersion != expected) {
logger.error("--> FAILED: idVersion={} actualVersion= {}", idVersion, actualVersion);
failed = true;
@ -839,11 +839,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
client().prepareDelete("test", "type", "id").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet();
// Real-time get should reflect delete:
assertThat(
"doc should have been deleted",
client().prepareGet("test", "type", "id").execute().actionGet().getVersion(),
equalTo(-1L)
);
assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L));
// ThreadPool.relativeTimeInMillis has default granularity of 200 msec, so we must sleep at least that long; sleep much longer in
// case system is busy:
@ -853,11 +849,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
client().prepareDelete("test", "type", "id2").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet();
// Real-time get should still reflect delete:
assertThat(
"doc should have been deleted",
client().prepareGet("test", "type", "id").execute().actionGet().getVersion(),
equalTo(-1L)
);
assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L));
}
public void testGCDeletesZero() throws Exception {
@ -887,11 +879,7 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
client().prepareDelete("test", "type", "id").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet();
// Real-time get should reflect delete even though index.gc_deletes is 0:
assertThat(
"doc should have been deleted",
client().prepareGet("test", "type", "id").execute().actionGet().getVersion(),
equalTo(-1L)
);
assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L));
}
public void testSpecialVersioning() {

View File

@ -52,7 +52,7 @@ public class RoutingMissingException extends OpenSearchException {
}
public RoutingMissingException(String index, String type, String id) {
super("routing is required for [" + index + "]/[" + type + "]/[" + id + "]");
super("routing is required for [" + index + "]/[" + id + "]");
Objects.requireNonNull(index, "index must not be null");
Objects.requireNonNull(type, "type must not be null");
Objects.requireNonNull(id, "id must not be null");

View File

@ -206,7 +206,7 @@ public class TransportGetTaskAction extends HandledTransportAction<GetTaskReques
* coordinating node if the node is no longer part of the cluster.
*/
void getFinishedTaskFromIndex(Task thisTask, GetTaskRequest request, ActionListener<GetTaskResponse> listener) {
GetRequest get = new GetRequest(TaskResultsService.TASK_INDEX, TaskResultsService.TASK_TYPE, request.getTaskId().toString());
GetRequest get = new GetRequest(TaskResultsService.TASK_INDEX, request.getTaskId().toString());
get.setParentTask(clusterService.localNode().getId(), thisTask.getId());
client.get(get, ActionListener.wrap(r -> onGetFinishedTaskFromIndex(r, listener), e -> {

View File

@ -568,7 +568,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
docWriteRequest.routing(metadata.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index()));
// check if routing is required, if so, throw error if routing wasn't specified
if (docWriteRequest.routing() == null && metadata.routingRequired(concreteIndex.getName())) {
throw new RoutingMissingException(concreteIndex.getName(), docWriteRequest.type(), docWriteRequest.id());
throw new RoutingMissingException(concreteIndex.getName(), docWriteRequest.id());
}
break;
default:

View File

@ -140,7 +140,7 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
try {
// No need to check the type, IndexShard#get does it for us
Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(request.id()));
result = context.indexShard().get(new Engine.Get(false, false, request.type(), request.id(), uidTerm));
result = context.indexShard().get(new Engine.Get(false, false, request.id(), uidTerm));
if (!result.exists()) {
return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), false);
}
@ -158,7 +158,7 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
// doc isn't deleted between the initial get and this call.
GetResult getResult = context.indexShard()
.getService()
.get(result, request.id(), request.type(), request.storedFields(), request.fetchSourceContext());
.get(result, request.id(), request.storedFields(), request.fetchSourceContext());
return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation, getResult);
} else {
return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation);

View File

@ -33,11 +33,11 @@
package org.opensearch.action.get;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.RealtimeRequest;
import org.opensearch.action.ValidateActions;
import org.opensearch.action.support.single.shard.SingleShardRequest;
import org.opensearch.common.Nullable;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
@ -54,7 +54,7 @@ import static org.opensearch.action.ValidateActions.addValidationError;
* A request to get a document (its source) from an index based on its id. Best created using
* {@link org.opensearch.client.Requests#getRequest(String)}.
* <p>
* The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)}
* The operation requires the {@link #index()}} and {@link #id(String)}
* to be set.
*
* @see GetResponse
@ -63,7 +63,6 @@ import static org.opensearch.action.ValidateActions.addValidationError;
*/
public class GetRequest extends SingleShardRequest<GetRequest> implements RealtimeRequest {
private String type;
private String id;
private String routing;
private String preference;
@ -79,13 +78,13 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
private VersionType versionType = VersionType.INTERNAL;
private long version = Versions.MATCH_ANY;
public GetRequest() {
type = MapperService.SINGLE_MAPPING_NAME;
}
public GetRequest() {}
GetRequest(StreamInput in) throws IOException {
super(in);
type = in.readString();
if (in.getVersion().before(Version.V_2_0_0)) {
in.readString();
}
id = in.readString();
routing = in.readOptionalString();
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
@ -106,22 +105,6 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
*/
public GetRequest(String index) {
super(index);
this.type = MapperService.SINGLE_MAPPING_NAME;
}
/**
* Constructs a new get request against the specified index with the type and id.
*
* @param index The index to get the document from
* @param type The type of the document
* @param id The id of the document
* @deprecated Types are in the process of being removed, use {@link GetRequest(String, String)} instead.
*/
@Deprecated
public GetRequest(String index, String type, String id) {
super(index);
this.type = type;
this.id = id;
}
/**
@ -133,15 +116,11 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
public GetRequest(String index, String id) {
super(index);
this.id = id;
this.type = MapperService.SINGLE_MAPPING_NAME;
}
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = super.validateNonNullIndex();
if (Strings.isEmpty(type)) {
validationException = addValidationError("type is missing", validationException);
}
if (Strings.isEmpty(id)) {
validationException = addValidationError("id is missing", validationException);
}
@ -154,19 +133,6 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
return validationException;
}
/**
* Sets the type of the document to fetch.
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public GetRequest type(@Nullable String type) {
if (type == null) {
type = MapperService.SINGLE_MAPPING_NAME;
}
this.type = type;
return this;
}
/**
* Sets the id of the document to fetch.
*/
@ -194,14 +160,6 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
return this;
}
/**
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String type() {
return type;
}
public String id() {
return id;
}
@ -295,7 +253,9 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(type);
if (out.getVersion().before(Version.V_2_0_0)) {
out.writeString(MapperService.SINGLE_MAPPING_NAME);
}
out.writeString(id);
out.writeOptionalString(routing);
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
@ -313,7 +273,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
@Override
public String toString() {
return "get [" + index + "][" + type + "][" + id + "]: routing [" + routing + "]";
return "get [" + index + "][" + id + "]: routing [" + routing + "]";
}
}

View File

@ -52,15 +52,6 @@ public class GetRequestBuilder extends SingleShardOperationRequestBuilder<GetReq
super(client, action, new GetRequest(index));
}
/**
* Sets the type of the document to fetch. If set to {@code null}, will use just the id to fetch the
* first document matching it.
*/
public GetRequestBuilder setType(@Nullable String type) {
request.type(type);
return this;
}
/**
* Sets the id of the document to fetch.
*/

View File

@ -84,13 +84,6 @@ public class GetResponse extends ActionResponse implements Iterable<DocumentFiel
return getResult.getIndex();
}
/**
* The type of the document.
*/
public String getType() {
return getResult.getType();
}
/**
* The id of the document.
*/
@ -209,10 +202,10 @@ public class GetResponse extends ActionResponse implements Iterable<DocumentFiel
// At this stage we ensure that we parsed enough information to return
// a valid GetResponse instance. If it's not the case, we throw an
// exception so that callers know it and can handle it correctly.
if (getResult.getIndex() == null && getResult.getType() == null && getResult.getId() == null) {
if (getResult.getIndex() == null && getResult.getId() == null) {
throw new ParsingException(
parser.getTokenLocation(),
String.format(Locale.ROOT, "Missing required fields [%s,%s,%s]", GetResult._INDEX, GetResult._TYPE, GetResult._ID)
String.format(Locale.ROOT, "Missing required fields [%s,%s]", GetResult._INDEX, GetResult._ID)
);
}
return new GetResponse(getResult);

View File

@ -71,16 +71,6 @@ public class MultiGetItemResponse implements Writeable {
return response.getIndex();
}
/**
* The type of the document.
*/
public String getType() {
if (failure != null) {
return failure.getType();
}
return response.getType();
}
/**
* The id of the document.
*/

View File

@ -34,6 +34,7 @@ package org.opensearch.action.get;
import org.opensearch.LegacyESVersion;
import org.opensearch.OpenSearchParseException;
import org.opensearch.Version;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.CompositeIndicesRequest;
@ -54,6 +55,7 @@ import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.common.xcontent.XContentParser.Token;
import org.opensearch.index.VersionType;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.search.fetch.subphase.FetchSourceContext;
import java.io.IOException;
@ -73,7 +75,6 @@ public class MultiGetRequest extends ActionRequest
private static final ParseField DOCS = new ParseField("docs");
private static final ParseField INDEX = new ParseField("_index");
private static final ParseField TYPE = new ParseField("_type");
private static final ParseField ID = new ParseField("_id");
private static final ParseField ROUTING = new ParseField("routing");
private static final ParseField VERSION = new ParseField("version");
@ -88,7 +89,6 @@ public class MultiGetRequest extends ActionRequest
public static class Item implements Writeable, IndicesRequest, ToXContentObject {
private String index;
private String type;
private String id;
private String routing;
private String[] storedFields;
@ -102,7 +102,9 @@ public class MultiGetRequest extends ActionRequest
public Item(StreamInput in) throws IOException {
index = in.readString();
type = in.readOptionalString();
if (in.getVersion().before(Version.V_2_0_0)) {
in.readOptionalString();
}
id = in.readString();
routing = in.readOptionalString();
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
@ -115,22 +117,6 @@ public class MultiGetRequest extends ActionRequest
fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new);
}
/**
* Constructs a single get item.
*
* @param index The index name
* @param type The type (can be null)
* @param id The id
*
* @deprecated Types are in the process of being removed, use {@link Item(String, String) instead}.
*/
@Deprecated
public Item(String index, @Nullable String type, String id) {
this.index = index;
this.type = type;
this.id = id;
}
public Item(String index, String id) {
this.index = index;
this.id = id;
@ -155,10 +141,6 @@ public class MultiGetRequest extends ActionRequest
return this;
}
public String type() {
return this.type;
}
public String id() {
return this.id;
}
@ -217,7 +199,9 @@ public class MultiGetRequest extends ActionRequest
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
out.writeOptionalString(type);
if (out.getVersion().before(Version.V_2_0_0)) {
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
}
out.writeString(id);
out.writeOptionalString(routing);
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
@ -234,7 +218,6 @@ public class MultiGetRequest extends ActionRequest
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(INDEX.getPreferredName(), index);
builder.field(TYPE.getPreferredName(), type);
builder.field(ID.getPreferredName(), id);
builder.field(ROUTING.getPreferredName(), routing);
builder.field(STORED_FIELDS.getPreferredName(), storedFields);
@ -259,7 +242,6 @@ public class MultiGetRequest extends ActionRequest
if (!id.equals(item.id)) return false;
if (!index.equals(item.index)) return false;
if (routing != null ? !routing.equals(item.routing) : item.routing != null) return false;
if (type != null ? !type.equals(item.type) : item.type != null) return false;
if (versionType != item.versionType) return false;
return true;
@ -268,7 +250,6 @@ public class MultiGetRequest extends ActionRequest
@Override
public int hashCode() {
int result = index.hashCode();
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + id.hashCode();
result = 31 * result + (routing != null ? routing.hashCode() : 0);
result = 31 * result + (storedFields != null ? Arrays.hashCode(storedFields) : 0);
@ -308,16 +289,6 @@ public class MultiGetRequest extends ActionRequest
return this;
}
/**
* @deprecated Types are in the process of being removed, use
* {@link MultiGetRequest#add(String, String)} instead.
*/
@Deprecated
public MultiGetRequest add(String index, @Nullable String type, String id) {
items.add(new Item(index, type, id));
return this;
}
public MultiGetRequest add(String index, String id) {
items.add(new Item(index, id));
return this;
@ -377,7 +348,6 @@ public class MultiGetRequest extends ActionRequest
public MultiGetRequest add(
@Nullable String defaultIndex,
@Nullable String defaultType,
@Nullable String[] defaultFields,
@Nullable FetchSourceContext defaultFetchSource,
@Nullable String defaultRouting,
@ -395,18 +365,9 @@ public class MultiGetRequest extends ActionRequest
currentFieldName = parser.currentName();
} else if (token == Token.START_ARRAY) {
if ("docs".equals(currentFieldName)) {
parseDocuments(
parser,
this.items,
defaultIndex,
defaultType,
defaultFields,
defaultFetchSource,
defaultRouting,
allowExplicitIndex
);
parseDocuments(parser, this.items, defaultIndex, defaultFields, defaultFetchSource, defaultRouting, allowExplicitIndex);
} else if ("ids".equals(currentFieldName)) {
parseIds(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting);
parseIds(parser, this.items, defaultIndex, defaultFields, defaultFetchSource, defaultRouting);
} else {
final String message = String.format(
Locale.ROOT,
@ -434,7 +395,6 @@ public class MultiGetRequest extends ActionRequest
XContentParser parser,
List<Item> items,
@Nullable String defaultIndex,
@Nullable String defaultType,
@Nullable String[] defaultFields,
@Nullable FetchSourceContext defaultFetchSource,
@Nullable String defaultRouting,
@ -447,7 +407,6 @@ public class MultiGetRequest extends ActionRequest
throw new IllegalArgumentException("docs array element should include an object");
}
String index = defaultIndex;
String type = defaultType;
String id = null;
String routing = defaultRouting;
List<String> storedFields = null;
@ -465,8 +424,6 @@ public class MultiGetRequest extends ActionRequest
throw new IllegalArgumentException("explicit index in multi get is not allowed");
}
index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
type = parser.text();
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
id = parser.text();
} else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) {
@ -565,7 +522,7 @@ public class MultiGetRequest extends ActionRequest
aFields = defaultFields;
}
items.add(
new Item(index, type, id).routing(routing)
new Item(index, id).routing(routing)
.storedFields(aFields)
.version(version)
.versionType(versionType)
@ -578,7 +535,6 @@ public class MultiGetRequest extends ActionRequest
XContentParser parser,
List<Item> items,
@Nullable String defaultIndex,
@Nullable String defaultType,
@Nullable String[] defaultFields,
@Nullable FetchSourceContext defaultFetchSource,
@Nullable String defaultRouting
@ -589,7 +545,7 @@ public class MultiGetRequest extends ActionRequest
throw new IllegalArgumentException("ids array element should only contain ids");
}
items.add(
new Item(defaultIndex, defaultType, parser.text()).storedFields(defaultFields)
new Item(defaultIndex, parser.text()).storedFields(defaultFields)
.fetchSourceContext(defaultFetchSource)
.routing(defaultRouting)
);

View File

@ -34,7 +34,6 @@ package org.opensearch.action.get;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.common.Nullable;
/**
* A multi get document action request builder.
@ -45,21 +44,21 @@ public class MultiGetRequestBuilder extends ActionRequestBuilder<MultiGetRequest
super(client, action, new MultiGetRequest());
}
public MultiGetRequestBuilder add(String index, @Nullable String type, String id) {
request.add(index, type, id);
public MultiGetRequestBuilder add(String index, String id) {
request.add(index, id);
return this;
}
public MultiGetRequestBuilder add(String index, @Nullable String type, Iterable<String> ids) {
public MultiGetRequestBuilder add(String index, Iterable<String> ids) {
for (String id : ids) {
request.add(index, type, id);
request.add(index, id);
}
return this;
}
public MultiGetRequestBuilder add(String index, @Nullable String type, String... ids) {
public MultiGetRequestBuilder add(String index, String... ids) {
for (String id : ids) {
request.add(index, type, id);
request.add(index, id);
}
return this;
}

View File

@ -33,6 +33,7 @@
package org.opensearch.action.get;
import org.opensearch.OpenSearchException;
import org.opensearch.Version;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput;
@ -43,6 +44,7 @@ import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.common.xcontent.XContentParser.Token;
import org.opensearch.index.get.GetResult;
import org.opensearch.index.mapper.MapperService;
import java.io.IOException;
import java.util.ArrayList;
@ -53,7 +55,6 @@ import java.util.List;
public class MultiGetResponse extends ActionResponse implements Iterable<MultiGetItemResponse>, ToXContentObject {
private static final ParseField INDEX = new ParseField("_index");
private static final ParseField TYPE = new ParseField("_type");
private static final ParseField ID = new ParseField("_id");
private static final ParseField ERROR = new ParseField("error");
private static final ParseField DOCS = new ParseField("docs");
@ -64,20 +65,20 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
public static class Failure implements Writeable, ToXContentObject {
private final String index;
private final String type;
private final String id;
private final Exception exception;
public Failure(String index, String type, String id, Exception exception) {
public Failure(String index, String id, Exception exception) {
this.index = index;
this.type = type;
this.id = id;
this.exception = exception;
}
Failure(StreamInput in) throws IOException {
index = in.readString();
type = in.readOptionalString();
if (in.getVersion().before(Version.V_2_0_0)) {
in.readOptionalString();
}
id = in.readString();
exception = in.readException();
}
@ -89,13 +90,6 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
return this.index;
}
/**
* The type of the action.
*/
public String getType() {
return type;
}
/**
* The id of the action.
*/
@ -113,7 +107,9 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
out.writeOptionalString(type);
if (out.getVersion().before(Version.V_2_0_0)) {
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
}
out.writeString(id);
out.writeException(exception);
}
@ -122,7 +118,6 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(INDEX.getPreferredName(), index);
builder.field(TYPE.getPreferredName(), type);
builder.field(ID.getPreferredName(), id);
OpenSearchException.generateFailureXContent(builder, params, exception, true);
builder.endObject();
@ -201,7 +196,6 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
private static MultiGetItemResponse parseItem(XContentParser parser) throws IOException {
String currentFieldName = null;
String index = null;
String type = null;
String id = null;
OpenSearchException exception = null;
GetResult getResult = null;
@ -210,17 +204,14 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
case FIELD_NAME:
currentFieldName = parser.currentName();
if (INDEX.match(currentFieldName, parser.getDeprecationHandler()) == false
&& TYPE.match(currentFieldName, parser.getDeprecationHandler()) == false
&& ID.match(currentFieldName, parser.getDeprecationHandler()) == false
&& ERROR.match(currentFieldName, parser.getDeprecationHandler()) == false) {
getResult = GetResult.fromXContentEmbedded(parser, index, type, id);
getResult = GetResult.fromXContentEmbedded(parser, index, id);
}
break;
case VALUE_STRING:
if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
type = parser.text();
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
id = parser.text();
}
@ -241,7 +232,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
}
if (exception != null) {
return new MultiGetItemResponse(null, new Failure(index, type, id, exception));
return new MultiGetItemResponse(null, new Failure(index, id, exception));
} else {
GetResponse getResponse = new GetResponse(getResult);
return new MultiGetItemResponse(getResponse, null);

View File

@ -104,7 +104,7 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
request.request().routing(state.metadata().resolveIndexRouting(request.request().routing(), request.request().index()));
// Fail fast on the node that received the request.
if (request.request().routing() == null && state.getMetadata().routingRequired(request.concreteIndex())) {
throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id());
throw new RoutingMissingException(request.concreteIndex(), request.request().id());
}
}
@ -136,7 +136,6 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
GetResult result = indexShard.getService()
.get(
request.type(),
request.id(),
request.storedFields(),
request.realtime(),

View File

@ -89,17 +89,12 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
if ((item.routing() == null) && (clusterState.getMetadata().routingRequired(concreteSingleIndex))) {
responses.set(
i,
newItemFailure(
concreteSingleIndex,
item.type(),
item.id(),
new RoutingMissingException(concreteSingleIndex, item.type(), item.id())
)
newItemFailure(concreteSingleIndex, item.id(), new RoutingMissingException(concreteSingleIndex, item.id()))
);
continue;
}
} catch (Exception e) {
responses.set(i, newItemFailure(item.index(), item.type(), item.id(), e));
responses.set(i, newItemFailure(item.index(), item.id(), e));
continue;
}
@ -148,7 +143,7 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
// create failures for all relevant requests
for (int i = 0; i < shardRequest.locations.size(); i++) {
MultiGetRequest.Item item = shardRequest.items.get(i);
responses.set(shardRequest.locations.get(i), newItemFailure(shardRequest.index(), item.type(), item.id(), e));
responses.set(shardRequest.locations.get(i), newItemFailure(shardRequest.index(), item.id(), e));
}
if (counter.decrementAndGet() == 0) {
finishHim();
@ -162,7 +157,7 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
}
}
private static MultiGetItemResponse newItemFailure(String index, String type, String id, Exception exception) {
return new MultiGetItemResponse(null, new MultiGetResponse.Failure(index, type, id, exception));
private static MultiGetItemResponse newItemFailure(String index, String id, Exception exception) {
return new MultiGetItemResponse(null, new MultiGetResponse.Failure(index, id, exception));
}
}

View File

@ -134,25 +134,14 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
MultiGetRequest.Item item = request.items.get(i);
try {
GetResult getResult = indexShard.getService()
.get(
item.type(),
item.id(),
item.storedFields(),
request.realtime(),
item.version(),
item.versionType(),
item.fetchSourceContext()
);
.get(item.id(), item.storedFields(), request.realtime(), item.version(), item.versionType(), item.fetchSourceContext());
response.add(request.locations.get(i), new GetResponse(getResult));
} catch (RuntimeException e) {
if (TransportActions.isShardNotAvailableException(e)) {
throw e;
} else {
logger.debug(
() -> new ParameterizedMessage("{} failed to execute multi_get for [{}]/[{}]", shardId, item.type(), item.id()),
e
);
response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.type(), item.id(), e));
logger.debug(() -> new ParameterizedMessage("{} failed to execute multi_get for [{}]", shardId, item.id()), e);
response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.id(), e));
}
}
}

View File

@ -51,6 +51,7 @@ import org.opensearch.index.VersionType;
import org.opensearch.index.engine.DocumentMissingException;
import org.opensearch.index.engine.DocumentSourceMissingException;
import org.opensearch.index.get.GetResult;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.mapper.RoutingFieldMapper;
import org.opensearch.index.shard.IndexShard;
import org.opensearch.index.shard.ShardId;
@ -82,8 +83,7 @@ public class UpdateHelper {
* Prepares an update request by converting it into an index or delete request or an update response (no action).
*/
public Result prepare(UpdateRequest request, IndexShard indexShard, LongSupplier nowInMillis) {
final GetResult getResult = indexShard.getService()
.getForUpdate(request.type(), request.id(), request.ifSeqNo(), request.ifPrimaryTerm());
final GetResult getResult = indexShard.getService().getForUpdate(request.id(), request.ifSeqNo(), request.ifPrimaryTerm());
return prepare(indexShard.shardId(), request, getResult, nowInMillis);
}
@ -156,7 +156,7 @@ public class UpdateHelper {
case NONE:
UpdateResponse update = new UpdateResponse(
shardId,
getResult.getType(),
MapperService.SINGLE_MAPPING_NAME,
getResult.getId(),
getResult.getSeqNo(),
getResult.getPrimaryTerm(),
@ -221,7 +221,7 @@ public class UpdateHelper {
if (detectNoop && noop) {
UpdateResponse update = new UpdateResponse(
shardId,
getResult.getType(),
MapperService.SINGLE_MAPPING_NAME,
getResult.getId(),
getResult.getSeqNo(),
getResult.getPrimaryTerm(),
@ -271,7 +271,6 @@ public class UpdateHelper {
Map<String, Object> ctx = new HashMap<>(16);
ctx.put(ContextFields.OP, UpdateOpType.INDEX.toString()); // The default operation is "index"
ctx.put(ContextFields.INDEX, getResult.getIndex());
ctx.put(ContextFields.TYPE, getResult.getType());
ctx.put(ContextFields.ID, getResult.getId());
ctx.put(ContextFields.VERSION, getResult.getVersion());
ctx.put(ContextFields.ROUTING, routing);
@ -313,7 +312,7 @@ public class UpdateHelper {
// If it was neither an INDEX or DELETE operation, treat it as a noop
UpdateResponse update = new UpdateResponse(
shardId,
getResult.getType(),
MapperService.SINGLE_MAPPING_NAME,
getResult.getId(),
getResult.getSeqNo(),
getResult.getPrimaryTerm(),
@ -386,7 +385,6 @@ public class UpdateHelper {
// TODO when using delete/none, we can still return the source as bytes by generating it (using the sourceContentType)
return new GetResult(
concreteIndex,
request.type(),
request.id(),
seqNo,
primaryTerm,

View File

@ -38,6 +38,7 @@ import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.index.get.GetResult;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.shard.ShardId;
import org.opensearch.rest.RestStatus;
@ -83,7 +84,7 @@ public class UpdateResponse extends DocWriteResponse {
long version,
Result result
) {
super(shardId, type, id, seqNo, primaryTerm, version, result);
super(shardId, MapperService.SINGLE_MAPPING_NAME, id, seqNo, primaryTerm, version, result);
setShardInfo(shardInfo);
}
@ -198,7 +199,6 @@ public class UpdateResponse extends DocWriteResponse {
update.setGetResult(
new GetResult(
update.getIndex(),
update.getType(),
update.getId(),
getResult.getSeqNo(),
getResult.getPrimaryTerm(),

View File

@ -271,9 +271,9 @@ public interface Client extends OpenSearchClient, Releasable {
GetRequestBuilder prepareGet();
/**
* Gets the document that was indexed from an index with a type (optional) and id.
* Gets the document that was indexed from an index with an id.
*/
GetRequestBuilder prepareGet(String index, @Nullable String type, String id);
GetRequestBuilder prepareGet(String index, String id);
/**
* Multi get documents.

View File

@ -129,7 +129,7 @@ public class Requests {
/**
* Creates a get request to get the JSON source from an index based on a type and id. Note, the
* {@link GetRequest#type(String)} and {@link GetRequest#id(String)} must be set.
* {@link GetRequest#id(String)} must be set.
*
* @param index The index to get the JSON source from
* @return The get request

View File

@ -532,8 +532,8 @@ public abstract class AbstractClient implements Client {
}
@Override
public GetRequestBuilder prepareGet(String index, String type, String id) {
return prepareGet().setIndex(index).setType(type).setId(id);
public GetRequestBuilder prepareGet(String index, String id) {
return prepareGet().setIndex(index).setId(id);
}
@Override

View File

@ -1704,16 +1704,15 @@ public abstract class Engine implements Closeable {
public static class Get {
private final boolean realtime;
private final Term uid;
private final String type, id;
private final String id;
private final boolean readFromTranslog;
private long version = Versions.MATCH_ANY;
private VersionType versionType = VersionType.INTERNAL;
private long ifSeqNo = UNASSIGNED_SEQ_NO;
private long ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM;
public Get(boolean realtime, boolean readFromTranslog, String type, String id, Term uid) {
public Get(boolean realtime, boolean readFromTranslog, String id, Term uid) {
this.realtime = realtime;
this.type = type;
this.id = id;
this.uid = uid;
this.readFromTranslog = readFromTranslog;
@ -1723,10 +1722,6 @@ public abstract class Engine implements Closeable {
return this.realtime;
}
public String type() {
return type;
}
public String id() {
return id;
}

Some files were not shown because too many files have changed in this diff Show More