Can't generate an OR query with a nested must_not filter
See original GitHub issueI’m trying to generate the following query: select all records, where a nested prop1.id is 1 OR nested prop1 doesn't exist
.
Here is a working elasticsearch object example which does what I need:
{
"query": {
"bool": {
"filter": {
"bool": {
"should": [
{
"nested": {
"path": "prop1",
"query": {
"term": {
"prop1.id": "1"
}
}
}
},
{
"bool": {
"must_not": [ {
"nested": {
"path": "prop1",
"query": {
"exists": {
"field": "prop1"
}
}
}
} ]
}
}
]
}
}
}
}
}
The question is - how do I generate such a query with bodybuilder? I can generate the first part with
bodybuilder()
.orFilter('nested', 'path', 'prop1', q => {
return q.query('terms', 'prop1.id', '1');
})
.build();
But how do I add the nested must_not
part to it? Any advices?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
ElasticSearch should with nested and bool must_not exists
I want to use the categories field to return documents that either: have a score above a threshold in a given category, or;...
Read more >MUST_NOT not working with EXIST in NESTED query
So I tried a nested query, but it returns no result. POST players/players/_search { "query": { "bool": { "filter": [ { "nested": {...
Read more >How to Query Elasticsearch With Boolean Queries - Dattell
Boolean queries in Elasticsearch match documents by using the clauses: filter, must, must_not, & should. Read on for examples of bool queries.
Read more >Invalid sub-query filter. Either data cannot be retrieved (null) or ...
SAP Documentation. Search · SAP Help Portal | SAP Community Network | SAP Support Portal. Expand All Collapse All. Previous topic ...
Read more >SODA Filter Specifications (Reference) - Oracle Help Center
SODA query operations use a QBE to select all JSON documents in a collection ... That is, you cannot nest a composite filter...
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
this got me quite close. Does that work for your case?
Ok, looks like a could achieve that in a little bit hacky way:
But I’m still wondering - is there a way to get the same query object without accessing query object internals?