I have a query that looks like this:
{
"query": {
"constant_score":
"filter": {
"missing": {
"field": "parent_id"
}
}
}
},
"size": limit,
"from": offset
}
My type has a parent_id and a wall_id field. How can I modify this query so that I can get all types that do not have a parent_id and do not have a wall_id? I can't seem to decipher it from the docs. Thanks for any help offered!
UPDATE
I have the following query that works, but I don't like the catchall query on the title. Is there a way to do this without having to add a "catchall?
{
"query":{
"filtered":{
"query":{
"field":{ "title":"*" }
},
"filter":{
"and":{
"filters":[
{
"missing":{ "field":"parent_id" }
},
{
"missing":{ "field":"wall_id" }
}
]
}
}
}
}, "size":10, "from":0
}
Query DSLedit. Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries. Think of the Query DSL as an AST (Abstract Syntax Tree) of queries, consisting of two types of clauses: Leaf query clauses.
Boolean, or a bool query in Elasticsearch, is a type of search that allows you to combine conditions using Boolean conditions. Elasticsearch will search the document in the specified index and return all the records matching the combination of Boolean clauses.
Boolean queryedit. A query that matches documents matching boolean combinations of other queries. The bool query maps to Lucene BooleanQuery . It is built using one or more boolean clauses, each clause with a typed occurrence.
You're almost there, you just need to use the and filter under your constant_score query:
{
"query": {
"constant_score": {
"filter": {
"and":[
{ "missing":{ "field":"parent_id" }},
{ "missing":{ "field":"wall_id" }}
]
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With