My query looks like this
{
"query": {
"bool": {
"must": [
{
"has_parent": {
"parent_type": "doc",
"query": {
"bool": {
"must": [
{
"terms": {
"id": [
713
]}},
{
"range": {
"created": {
"lte": "now/d"
}}},
{
"range": {"expires": { "gte": "now/d"
}}}]
}}}},
{
"term": {
"doc_type": "item"
}},
{"bool": {"should": [
{
"term": {
"have_prices": true}},
{
"term": {
"is_folder": true
}}]}}],
"must_not": {
"exists": {
"field": "folder"
}}}
},
"sort": [
{
"is_folder": {
"order": "desc"}},
{
"title_low.order": {
"order": "asc"
}
}
],
"size": 1000
}
and I get some result, like this one
"hits": {
"total": 19,
"max_score": null,
"hits": [
{
"_index": "prices",
"_type": "doc",
"_id": "item-6800004",
"_score": null,
"_routing": "1",
"_source": {
"id": 6800004,
"id_pricedoc": 713,
"title": ""Π²ΠΎΠ΄ΠΊΠ° β1" 1",
"title_low": ""Π²ΠΎΠ΄ΠΊΠ° β1" 1",
"supplier": {
"id": 7831,
"type": null
},
"supplier_nom": {
"id": 1375697,
"market_nom": {
"id": null
},
"codes": null,
"sup_code": "7a6713a5-73c1-3acb-9b62-9e38b2314dce",
"manufacturer": {
"id": null,
"title": null
}
},
"is_folder": false,
"folder": null,
"path": null,
"pricedoc_created": "2016-03-21",
"prices": [
{
"currency": "RUR",
"id_offer": 15735967,
"id_prcknd": 167,
"value": "391.50"
}
],
"have_prices": true,
"market": {
"title": null,
"uuid": null,
"folder": null,
"path": null
},
"_join_field_name": "doc_type",
"doc_type": {
"name": "item",
"parent": "doc-713"
}
},
"sort": [
0,
""Π²ΠΎΠ΄ΠΊΠ° β1" 1"
]
}
Now I would like to modify query that will matches docs witch only "id_prcknd": 167. I wrote something like this
{
"query": {
"bool": {
"must": [
{
"has_parent": {
"parent_type": "doc",
"query": {
"bool": {
"must": [
{
"terms": {
"id": [
713
]
}
},
{
"range": {
"created": {
"lte": "now/d"
}
}
},
{
"range": {
"expires": {
"gte": "now/d"
}}}]}}}},
{
"term": {
"doc_type": "item"
}
},
{
"bool": {
"should": [
{
"term": {
"have_prices": true
}
},
{
"term": {
"is_folder": true
}}]}
}
],
"must_not": {
"exists": {
"field": "folder"
}
}
},
"nested": {
"path": "prices",
"query": {
"bool": {
"must": [
{
"match": {
"prices.id_prcknd": 167
}}]}
}
},
"sort": [
{
"is_folder": {
"order": "desc"
}
},
{
"title_low.order": {
"order": "asc"
}
}
],
"size": 1000
}
But I got an error Elasticsearch malformed query, expected [END_OBJECT] but found [FIELD_NAME] Where am I wrong? I wanna match objects where "id_prcknd": 167