Nested Sub-query does not generate correct elastic search syntax.
See original GitHub issuebodybuilder()
.query('term', 'field', 'something')
.andQuery('bool', (q) => {
return q.query('term', 'obj1.color', 'blue')
})
.build()
generates bool.query which is not valid as per ES [bool] query does not support [query]
{
"query": {
"bool": {
"must": [
{
"term": {
"field": "something"
}
},
{
"bool": {
"query": {
"term": {
"obj1.color": "blue"
}
}
}
}
]
}
}
}
This is just simplistic scneario, I genuinely have some subqueries wiith nested path’s as well which does not work. I can come up with better example if this does not make sense.
Please advise if there is a workaround I can apply ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Nested query | Elasticsearch Guide [8.5] | Elastic
Wraps another query to search nested fields. The nested query searches nested field objects as if they were indexed as separate documents.
Read more >What is the ElasticSearch equivalent for an SQL subquery?
Elasticsearch doesn't support subqueries; you would need to perform your first query, then construct a second query using the results of the first...
Read more >ElasticSearch Nested Queries: How to Search for Embedded ...
This can happen when, for example, you have a nested JSON document, i.e., one JSON document inside another. This is because Lucene (i.e., ......
Read more >KNQL Plugin - The Daily Grok
In general you will never notice that nested queries are being generated, as this is done for you in the query parser. There...
Read more >Kibana Discover | KQL Nested Query | Examples - eduCBA
Kibana query helps us to explore our big data to convert useful information. The elastic search does an index of our data, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s a known-issue. You can’t have a single level nesting. If you think about it, it’s redundant. It can be brought up a level.
@johannes-scharlach Using filter instead of query will work, but filter and query have a different behavior regarding scoring (https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-filter-context.html).