|
@@ -305,11 +305,11 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
BulkRequest request = new BulkRequest();
|
|
|
- request.add(new IndexRequest("posts", "doc", "1")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "1")
|
|
|
.source(XContentType.JSON, "company", "Elastic", "age", 20));
|
|
|
- request.add(new IndexRequest("posts", "doc", "2")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "2")
|
|
|
.source(XContentType.JSON, "company", "Elastic", "age", 30));
|
|
|
- request.add(new IndexRequest("posts", "doc", "3")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "3")
|
|
|
.source(XContentType.JSON, "company", "Elastic", "age", 40));
|
|
|
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
|
|
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
|
|
@@ -381,10 +381,10 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
BulkRequest request = new BulkRequest();
|
|
|
- request.add(new IndexRequest("posts", "doc", "1").source(XContentType.JSON, "user", "kimchy"));
|
|
|
- request.add(new IndexRequest("posts", "doc", "2").source(XContentType.JSON, "user", "javanna"));
|
|
|
- request.add(new IndexRequest("posts", "doc", "3").source(XContentType.JSON, "user", "tlrx"));
|
|
|
- request.add(new IndexRequest("posts", "doc", "4").source(XContentType.JSON, "user", "cbuescher"));
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "1").source(XContentType.JSON, "user", "kimchy"));
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "2").source(XContentType.JSON, "user", "javanna"));
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "3").source(XContentType.JSON, "user", "tlrx"));
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "4").source(XContentType.JSON, "user", "cbuescher"));
|
|
|
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
|
|
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
|
|
|
assertSame(RestStatus.OK, bulkResponse.status());
|
|
@@ -424,13 +424,13 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
BulkRequest request = new BulkRequest();
|
|
|
- request.add(new IndexRequest("posts", "doc", "1")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "1")
|
|
|
.source(XContentType.JSON, "title", "In which order are my Elasticsearch queries executed?", "user",
|
|
|
Arrays.asList("kimchy", "luca"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- request.add(new IndexRequest("posts", "doc", "2")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "2")
|
|
|
.source(XContentType.JSON, "title", "Current status and upcoming changes in Elasticsearch", "user",
|
|
|
Arrays.asList("kimchy", "christoph"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- request.add(new IndexRequest("posts", "doc", "3")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "3")
|
|
|
.source(XContentType.JSON, "title", "The Future of Federated Search in Elasticsearch", "user",
|
|
|
Arrays.asList("kimchy", "tanguy"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
|
@@ -487,7 +487,7 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
public void testSearchRequestProfiling() throws IOException {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
- IndexRequest request = new IndexRequest("posts", "doc", "1")
|
|
|
+ IndexRequest request = new IndexRequest("posts", "_doc", "1")
|
|
|
.source(XContentType.JSON, "tags", "elasticsearch", "comments", 123);
|
|
|
request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);
|
|
|
IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);
|
|
@@ -559,11 +559,11 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
BulkRequest request = new BulkRequest();
|
|
|
- request.add(new IndexRequest("posts", "doc", "1")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "1")
|
|
|
.source(XContentType.JSON, "title", "In which order are my Elasticsearch queries executed?"));
|
|
|
- request.add(new IndexRequest("posts", "doc", "2")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "2")
|
|
|
.source(XContentType.JSON, "title", "Current status and upcoming changes in Elasticsearch"));
|
|
|
- request.add(new IndexRequest("posts", "doc", "3")
|
|
|
+ request.add(new IndexRequest("posts", "_doc", "3")
|
|
|
.source(XContentType.JSON, "title", "The Future of Federated Search in Elasticsearch"));
|
|
|
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
|
|
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
|
|
@@ -983,7 +983,7 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
|
|
|
// tag::explain-request
|
|
|
- ExplainRequest request = new ExplainRequest("contributors", "doc", "1");
|
|
|
+ ExplainRequest request = new ExplainRequest("contributors", "1");
|
|
|
request.query(QueryBuilders.termQuery("user", "tanguy"));
|
|
|
// end::explain-request
|
|
|
|
|
@@ -1009,16 +1009,14 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
|
|
|
// tag::explain-response
|
|
|
String index = response.getIndex(); // <1>
|
|
|
- String type = response.getType(); // <2>
|
|
|
- String id = response.getId(); // <3>
|
|
|
- boolean exists = response.isExists(); // <4>
|
|
|
- boolean match = response.isMatch(); // <5>
|
|
|
- boolean hasExplanation = response.hasExplanation(); // <6>
|
|
|
- Explanation explanation = response.getExplanation(); // <7>
|
|
|
- GetResult getResult = response.getGetResult(); // <8>
|
|
|
+ String id = response.getId(); // <2>
|
|
|
+ boolean exists = response.isExists(); // <3>
|
|
|
+ boolean match = response.isMatch(); // <4>
|
|
|
+ boolean hasExplanation = response.hasExplanation(); // <5>
|
|
|
+ Explanation explanation = response.getExplanation(); // <6>
|
|
|
+ GetResult getResult = response.getGetResult(); // <7>
|
|
|
// end::explain-response
|
|
|
assertThat(index, equalTo("contributors"));
|
|
|
- assertThat(type, equalTo("doc"));
|
|
|
assertThat(id, equalTo("1"));
|
|
|
assertTrue(exists);
|
|
|
assertTrue(match);
|
|
@@ -1251,29 +1249,29 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
|
|
|
private void indexSearchTestData() throws IOException {
|
|
|
CreateIndexRequest authorsRequest = new CreateIndexRequest("authors")
|
|
|
- .mapping("doc", "user", "type=keyword,doc_values=false");
|
|
|
+ .mapping("_doc", "user", "type=keyword,doc_values=false");
|
|
|
CreateIndexResponse authorsResponse = highLevelClient().indices().create(authorsRequest, RequestOptions.DEFAULT);
|
|
|
assertTrue(authorsResponse.isAcknowledged());
|
|
|
|
|
|
CreateIndexRequest reviewersRequest = new CreateIndexRequest("contributors")
|
|
|
- .mapping("doc", "user", "type=keyword,store=true");
|
|
|
+ .mapping("_doc", "user", "type=keyword,store=true");
|
|
|
CreateIndexResponse reviewersResponse = highLevelClient().indices().create(reviewersRequest, RequestOptions.DEFAULT);
|
|
|
assertTrue(reviewersResponse.isAcknowledged());
|
|
|
|
|
|
BulkRequest bulkRequest = new BulkRequest();
|
|
|
- bulkRequest.add(new IndexRequest("posts", "doc", "1")
|
|
|
+ bulkRequest.add(new IndexRequest("posts", "_doc", "1")
|
|
|
.source(XContentType.JSON, "title", "In which order are my Elasticsearch queries executed?", "user",
|
|
|
Arrays.asList("kimchy", "luca"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- bulkRequest.add(new IndexRequest("posts", "doc", "2")
|
|
|
+ bulkRequest.add(new IndexRequest("posts", "_doc", "2")
|
|
|
.source(XContentType.JSON, "title", "Current status and upcoming changes in Elasticsearch", "user",
|
|
|
Arrays.asList("kimchy", "christoph"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- bulkRequest.add(new IndexRequest("posts", "doc", "3")
|
|
|
+ bulkRequest.add(new IndexRequest("posts", "_doc", "3")
|
|
|
.source(XContentType.JSON, "title", "The Future of Federated Search in Elasticsearch", "user",
|
|
|
Arrays.asList("kimchy", "tanguy"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
|
|
|
- bulkRequest.add(new IndexRequest("authors", "doc", "1")
|
|
|
+ bulkRequest.add(new IndexRequest("authors", "_doc", "1")
|
|
|
.source(XContentType.JSON, "user", "kimchy"));
|
|
|
- bulkRequest.add(new IndexRequest("contributors", "doc", "1")
|
|
|
+ bulkRequest.add(new IndexRequest("contributors", "_doc", "1")
|
|
|
.source(XContentType.JSON, "user", "tanguy"));
|
|
|
|
|
|
|
|
@@ -1370,22 +1368,22 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
|
|
|
private static void indexCountTestData() throws IOException {
|
|
|
CreateIndexRequest authorsRequest = new CreateIndexRequest("author")
|
|
|
- .mapping("doc", "user", "type=keyword,doc_values=false");
|
|
|
+ .mapping("_doc", "user", "type=keyword,doc_values=false");
|
|
|
CreateIndexResponse authorsResponse = highLevelClient().indices().create(authorsRequest, RequestOptions.DEFAULT);
|
|
|
assertTrue(authorsResponse.isAcknowledged());
|
|
|
|
|
|
BulkRequest bulkRequest = new BulkRequest();
|
|
|
- bulkRequest.add(new IndexRequest("blog", "doc", "1")
|
|
|
+ bulkRequest.add(new IndexRequest("blog", "_doc", "1")
|
|
|
.source(XContentType.JSON, "title", "Doubling Down on Open?", "user",
|
|
|
Collections.singletonList("kimchy"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- bulkRequest.add(new IndexRequest("blog", "doc", "2")
|
|
|
+ bulkRequest.add(new IndexRequest("blog", "_doc", "2")
|
|
|
.source(XContentType.JSON, "title", "Swiftype Joins Forces with Elastic", "user",
|
|
|
Arrays.asList("kimchy", "matt"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
- bulkRequest.add(new IndexRequest("blog", "doc", "3")
|
|
|
+ bulkRequest.add(new IndexRequest("blog", "_doc", "3")
|
|
|
.source(XContentType.JSON, "title", "On Net Neutrality", "user",
|
|
|
Arrays.asList("tyler", "kimchy"), "innerObject", Collections.singletonMap("key", "value")));
|
|
|
|
|
|
- bulkRequest.add(new IndexRequest("author", "doc", "1")
|
|
|
+ bulkRequest.add(new IndexRequest("author", "_doc", "1")
|
|
|
.source(XContentType.JSON, "user", "kimchy"));
|
|
|
|
|
|
|