Skip to content

Commit

Permalink
Remove legacy mapping code. (elastic#29224)
Browse files Browse the repository at this point in the history
Some features have been deprecated since `6.0` like the `_parent` field or the
ability to have multiple types per index. This allows to remove quite some
code, which in-turn will hopefully make it easier to proceed with the removal
of types.
  • Loading branch information
jpountz authored Apr 11, 2018
1 parent 6949c88 commit 4918924
Show file tree
Hide file tree
Showing 226 changed files with 844 additions and 7,495 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ static Request delete(DeleteRequest deleteRequest) {

Params parameters = Params.builder();
parameters.withRouting(deleteRequest.routing());
parameters.withParent(deleteRequest.parent());
parameters.withTimeout(deleteRequest.timeout());
parameters.withVersion(deleteRequest.version());
parameters.withVersionType(deleteRequest.versionType());
Expand Down Expand Up @@ -315,9 +314,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException {
if (Strings.hasLength(request.routing())) {
metadata.field("routing", request.routing());
}
if (Strings.hasLength(request.parent())) {
metadata.field("parent", request.parent());
}
if (request.version() != Versions.MATCH_ANY) {
metadata.field("version", request.version());
}
Expand Down Expand Up @@ -394,7 +390,6 @@ static Request get(GetRequest getRequest) {
Params parameters = Params.builder();
parameters.withPreference(getRequest.preference());
parameters.withRouting(getRequest.routing());
parameters.withParent(getRequest.parent());
parameters.withRefresh(getRequest.refresh());
parameters.withRealtime(getRequest.realtime());
parameters.withStoredFields(getRequest.storedFields());
Expand Down Expand Up @@ -422,7 +417,6 @@ static Request index(IndexRequest indexRequest) {

Params parameters = Params.builder();
parameters.withRouting(indexRequest.routing());
parameters.withParent(indexRequest.parent());
parameters.withTimeout(indexRequest.timeout());
parameters.withVersion(indexRequest.version());
parameters.withVersionType(indexRequest.versionType());
Expand All @@ -446,7 +440,6 @@ static Request update(UpdateRequest updateRequest) throws IOException {

Params parameters = Params.builder();
parameters.withRouting(updateRequest.routing());
parameters.withParent(updateRequest.parent());
parameters.withTimeout(updateRequest.timeout());
parameters.withRefreshPolicy(updateRequest.getRefreshPolicy());
parameters.withWaitForActiveShards(updateRequest.waitForActiveShards());
Expand Down Expand Up @@ -711,10 +704,6 @@ Params withMasterTimeout(TimeValue masterTimeout) {
return putParam("master_timeout", masterTimeout);
}

Params withParent(String parent) {
return putParam("parent", parent);
}

Params withPipeline(String pipeline) {
return putParam("pipeline", pipeline);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,6 @@ public void testIndex() throws IOException {
"version conflict, current version [2] is different than the one provided [5]]", exception.getMessage());
assertEquals("index", exception.getMetadata("es.index").get(0));
}
{
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
IndexRequest indexRequest = new IndexRequest("index", "type", "missing_parent");
indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject());
indexRequest.parent("missing");

execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
});

assertEquals(RestStatus.BAD_REQUEST, exception.status());
assertEquals("Elasticsearch exception [type=illegal_argument_exception, " +
"reason=can't specify parent if no parent field has been configured]", exception.getMessage());
}
{
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
IndexRequest indexRequest = new IndexRequest("index", "type", "missing_pipeline");
Expand Down Expand Up @@ -456,22 +443,6 @@ public void testUpdate() throws IOException {
assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: version conflict, " +
"current version [2] is different than the one provided [1]]", exception.getMessage());
}
{
ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> {
UpdateRequest updateRequest = new UpdateRequest("index", "type", "id");
updateRequest.doc(singletonMap("field", "updated"), randomFrom(XContentType.values()));
if (randomBoolean()) {
updateRequest.parent("missing");
} else {
updateRequest.routing("missing");
}
execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
});

assertEquals(RestStatus.NOT_FOUND, exception.status());
assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[type][id]: document missing]",
exception.getMessage());
}
{
IndexRequest indexRequest = new IndexRequest("index", "type", "with_script");
indexRequest.source(singletonMap("counter", 12));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ public void testMultiGet() throws IOException {
if (randomBoolean()) {
item.routing(randomAlphaOfLength(4));
}
if (randomBoolean()) {
item.parent(randomAlphaOfLength(4));
}
if (randomBoolean()) {
item.storedFields(generateRandomStringArray(16, 8, false));
}
Expand Down Expand Up @@ -253,11 +250,6 @@ public void testDelete() {
deleteRequest.routing(routing);
expectedParams.put("routing", routing);
}
if (randomBoolean()) {
String parent = randomAlphaOfLengthBetween(3, 10);
deleteRequest.parent(parent);
expectedParams.put("parent", parent);
}
}

Request request = Request.delete(deleteRequest);
Expand Down Expand Up @@ -525,11 +517,6 @@ public void testIndex() throws IOException {
indexRequest.routing(routing);
expectedParams.put("routing", routing);
}
if (randomBoolean()) {
String parent = randomAlphaOfLengthBetween(3, 10);
indexRequest.parent(parent);
expectedParams.put("parent", parent);
}
if (randomBoolean()) {
String pipeline = randomAlphaOfLengthBetween(3, 10);
indexRequest.setPipeline(pipeline);
Expand Down Expand Up @@ -732,11 +719,6 @@ public void testUpdate() throws IOException {
updateRequest.routing(routing);
expectedParams.put("routing", routing);
}
if (randomBoolean()) {
String parent = randomAlphaOfLengthBetween(3, 10);
updateRequest.parent(parent);
expectedParams.put("parent", parent);
}
if (randomBoolean()) {
String timeout = randomTimeValue();
updateRequest.timeout(timeout);
Expand Down Expand Up @@ -840,15 +822,9 @@ public void testBulk() throws IOException {
if (randomBoolean()) {
indexRequest.setPipeline(randomAlphaOfLength(5));
}
if (randomBoolean()) {
indexRequest.parent(randomAlphaOfLength(5));
}
} else if (opType == DocWriteRequest.OpType.CREATE) {
IndexRequest createRequest = new IndexRequest(index, type, id).source(source, xContentType).create(true);
docWriteRequest = createRequest;
if (randomBoolean()) {
createRequest.parent(randomAlphaOfLength(5));
}
} else if (opType == DocWriteRequest.OpType.UPDATE) {
final UpdateRequest updateRequest = new UpdateRequest(index, type, id).doc(new IndexRequest().source(source, xContentType));
docWriteRequest = updateRequest;
Expand All @@ -858,9 +834,6 @@ public void testBulk() throws IOException {
if (randomBoolean()) {
randomizeFetchSourceContextParams(updateRequest::fetchSource, new HashMap<>());
}
if (randomBoolean()) {
updateRequest.parent(randomAlphaOfLength(5));
}
} else if (opType == DocWriteRequest.OpType.DELETE) {
docWriteRequest = new DeleteRequest(index, type, id);
} else {
Expand Down Expand Up @@ -902,7 +875,6 @@ public void testBulk() throws IOException {
assertEquals(originalRequest.type(), parsedRequest.type());
assertEquals(originalRequest.id(), parsedRequest.id());
assertEquals(originalRequest.routing(), parsedRequest.routing());
assertEquals(originalRequest.parent(), parsedRequest.parent());
assertEquals(originalRequest.version(), parsedRequest.version());
assertEquals(originalRequest.versionType(), parsedRequest.versionType());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ public void testIndex() throws Exception {
// tag::index-request-routing
request.routing("routing"); // <1>
// end::index-request-routing
// tag::index-request-parent
request.parent("parent"); // <1>
// end::index-request-parent
// tag::index-request-timeout
request.timeout(TimeValue.timeValueSeconds(1)); // <1>
request.timeout("1s"); // <2>
Expand Down Expand Up @@ -475,9 +472,6 @@ public void testUpdate() throws Exception {
// tag::update-request-routing
request.routing("routing"); // <1>
// end::update-request-routing
// tag::update-request-parent
request.parent("parent"); // <1>
// end::update-request-parent
// tag::update-request-timeout
request.timeout(TimeValue.timeValueSeconds(1)); // <1>
request.timeout("1s"); // <2>
Expand Down Expand Up @@ -583,9 +577,6 @@ public void testDelete() throws Exception {
// tag::delete-request-routing
request.routing("routing"); // <1>
// end::delete-request-routing
// tag::delete-request-parent
request.parent("parent"); // <1>
// end::delete-request-parent
// tag::delete-request-timeout
request.timeout(TimeValue.timeValueMinutes(2)); // <1>
request.timeout("2m"); // <2>
Expand Down Expand Up @@ -869,9 +860,6 @@ public void testGet() throws Exception {
//tag::get-request-routing
request.routing("routing"); // <1>
//end::get-request-routing
//tag::get-request-parent
request.parent("parent"); // <1>
//end::get-request-parent
//tag::get-request-preference
request.preference("preference"); // <1>
//end::get-request-preference
Expand Down Expand Up @@ -1122,8 +1110,6 @@ public void testMultiGet() throws Exception {
// tag::multi-get-request-item-extras
request.add(new MultiGetRequest.Item("index", "type", "with_routing")
.routing("some_routing")); // <1>
request.add(new MultiGetRequest.Item("index", "type", "with_parent")
.parent("some_parent")); // <2>
request.add(new MultiGetRequest.Item("index", "type", "with_version")
.versionType(VersionType.EXTERNAL) // <3>
.version(10123L)); // <4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testSearch() throws Exception {

// tag::search-source-sorting
sourceBuilder.sort(new ScoreSortBuilder().order(SortOrder.DESC)); // <1>
sourceBuilder.sort(new FieldSortBuilder("_uid").order(SortOrder.ASC)); // <2>
sourceBuilder.sort(new FieldSortBuilder("_id").order(SortOrder.ASC)); // <2>
// end::search-source-sorting

// tag::search-source-filtering-off
Expand Down
6 changes: 0 additions & 6 deletions docs/java-rest/high-level/document/delete.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-request-routing]
--------------------------------------------------
<1> Routing value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-request-parent]
--------------------------------------------------
<1> Parent value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-request-timeout]
Expand Down
6 changes: 0 additions & 6 deletions docs/java-rest/high-level/document/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-routing]
--------------------------------------------------
<1> Routing value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-parent]
--------------------------------------------------
<1> Parent value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-preference]
Expand Down
6 changes: 0 additions & 6 deletions docs/java-rest/high-level/document/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-request-routing]
--------------------------------------------------
<1> Routing value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-request-parent]
--------------------------------------------------
<1> Parent value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-request-timeout]
Expand Down
6 changes: 0 additions & 6 deletions docs/java-rest/high-level/document/update.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[update-request-routing]
--------------------------------------------------
<1> Routing value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[update-request-parent]
--------------------------------------------------
<1> Parent value

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[update-request-timeout]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docs/delete-by-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Which results in a sensible `total` like this one:
==== Automatic slicing

You can also let delete-by-query automatically parallelize using
<<sliced-scroll>> to slice on `_uid`. Use `slices` to specify the number of
<<sliced-scroll>> to slice on `_id`. Use `slices` to specify the number of
slices to use:

[source,js]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docs/update-by-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ Which results in a sensible `total` like this one:
==== Automatic slicing

You can also let update-by-query automatically parallelize using
<<sliced-scroll>> to slice on `_uid`. Use `slices` to specify the number of
<<sliced-scroll>> to slice on `_id`. Use `slices` to specify the number of
slices to use:

[source,js]
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/how-to/recipes/scoring.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ consistent across queries.

This work around has another benefit: when two documents have the same score,
they will be sorted by their internal Lucene doc id (which is unrelated to the
`_id` or `_uid`) by default. However these doc ids could be different across
copies of the same shard. So by always hitting the same shard, we would get
more consistent ordering of documents that have the same scores.
`_id`) by default. However these doc ids could be different across copies of
the same shard. So by always hitting the same shard, we would get more
consistent ordering of documents that have the same scores.

[float]
==== Relevancy looks wrong
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/mapping/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ can be customised when a mapping type is created.

The index to which the document belongs.

<<mapping-uid-field,`_uid`>>::

A composite field consisting of the `_type` and the `_id`.

<<mapping-type-field,`_type`>>::

The document's <<mapping-type,mapping type>>.
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/mapping/fields/id-field.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ Each document has an `_id` that uniquely identifies it, which is indexed
so that documents can be looked up either with the <<docs-get,GET API>> or the
<<query-dsl-ids-query,`ids` query>>.

NOTE: This was not the case with pre-6.0 indices due to the fact that they
supported multiple types, so the `_type` and `_id` were merged into a composite
primary key called `_uid`.

The value of the `_id` field is accessible in certain queries (`term`,
`terms`, `match`, `query_string`, `simple_query_string`).

Expand Down
Loading

0 comments on commit 4918924

Please sign in to comment.