From 6d5e24726f2f11ac5341e313393fb9120b16879c Mon Sep 17 00:00:00 2001 From: Isabel Drost-Fromm Date: Thu, 12 May 2016 12:29:18 +0200 Subject: [PATCH] Fix test failures. --- .../query-dsl/geo-polygon-query.asciidoc | 35 ++++++---------- .../reference/query-dsl/nested-query.asciidoc | 30 +++++++------- .../query-dsl/parent-id-query.asciidoc | 40 ++++++++++++++++--- 3 files changed, 61 insertions(+), 44 deletions(-) diff --git a/docs/reference/query-dsl/geo-polygon-query.asciidoc b/docs/reference/query-dsl/geo-polygon-query.asciidoc index 9a0800c7550..725abe91735 100644 --- a/docs/reference/query-dsl/geo-polygon-query.asciidoc +++ b/docs/reference/query-dsl/geo-polygon-query.asciidoc @@ -10,7 +10,7 @@ GET /_search { "query": { "bool" : { - "query" : { + "must": { "geo_polygon" : { "person.location" : { "points" : [ @@ -59,9 +59,6 @@ GET /_search "query": { "bool" : { "must" : { - "match_all" : {} - }, - "filter" : { "geo_polygon" : { "person.location" : { "points" : [ @@ -90,19 +87,16 @@ GET /_search "query": { "bool" : { "must" : { - "match_all" : {} - }, - "filter" : { - "geo_polygon" : { - "person.location" : { - "points" : [ - "40, -70", + "geo_polygon" : { + "person.location" : { + "points" : [ + "40, -70", "30, -80", "20, -90" - ] - } + ] } } + } } } } @@ -119,19 +113,16 @@ GET /_search "query": { "bool" : { "must" : { - "match_all" : {} - }, - "filter" : { - "geo_polygon" : { - "person.location" : { - "points" : [ - "drn5x1g8cu2y", + "geo_polygon" : { + "person.location" : { + "points" : [ + "drn5x1g8cu2y", "30, -80", "20, -90" - ] - } + ] } } + } } } } diff --git a/docs/reference/query-dsl/nested-query.asciidoc b/docs/reference/query-dsl/nested-query.asciidoc index 17ee20b983e..06720552bde 100644 --- a/docs/reference/query-dsl/nested-query.asciidoc +++ b/docs/reference/query-dsl/nested-query.asciidoc @@ -12,10 +12,12 @@ will work with: -------------------------------------------------- PUT /my_index { - "type1" : { - "properties" : { - "obj1" : { - "type" : "nested" + "mappings": { + "type1" : { + "properties" : { + "obj1" : { + "type" : "nested" + } } } } @@ -33,19 +35,15 @@ GET /_search "query": { "nested" : { "path" : "obj1", - "score_mode" : "avg", - "query" : { - "bool" : { - "must" : [ - { - "match" : {"obj1.name" : "blue"} - }, - { - "range" : {"obj1.count" : {"gt" : 5}} - } - ] - } + "score_mode" : "avg", + "query" : { + "bool" : { + "must" : [ + { "match" : {"obj1.name" : "blue"} }, + { "range" : {"obj1.count" : {"gt" : 5}} } + ] } + } } } } diff --git a/docs/reference/query-dsl/parent-id-query.asciidoc b/docs/reference/query-dsl/parent-id-query.asciidoc index 321adeecb5e..10cf6d05664 100644 --- a/docs/reference/query-dsl/parent-id-query.asciidoc +++ b/docs/reference/query-dsl/parent-id-query.asciidoc @@ -3,32 +3,60 @@ added[5.0.0] -The `parent_id` query can be used to find child documents which belong to a particular parent: +The `parent_id` query can be used to find child documents which belong to a +particular parent. Given the following mapping definition: [source,js] -------------------------------------------------- PUT /my_index { - "parent_id" : { - "type" : "blog_tag", - "id" : "1" + "mappings": { + "blog_post": { + "properties": { + "name": { + "type": "keyword" + } + } + }, + "blog_tag": { + "_parent": { + "type": "blog_post" + }, + "_routing": { + "required": true + } + } } } -------------------------------------------------- // CONSOLE // TESTSETUP +[source,js] +-------------------------------------------------- +GET /_search +{ + "query": { + "parent_id" : { + "type" : "blog_tag", + "id" : "1" + } + } +} +-------------------------------------------------- +// CONSOLE + The above is functionally equivalent to using the following <> query, but performs better as it does not need to do a join: [source,js] -------------------------------------------------- -GET /_search +GET /my_index/_search { "query": { "has_parent": { - "type": "blog", + "type": "blog_post", "query": { "term": { "_id": "1"