How to full text search and have filter? I want to search for a text among documents with language_id=10
. I've tried it this way:
{
"query": {
"query_string": {
"query": "Declared"
},
{
"filtered": {
"filter": {
"term": {
"language_id": 10
}
}
}
}
}
}
but seems like it's not correct. How to correct it?
A filter in Elasticsearch is all about applying some conditions inside the query that are used to narrow down the matching result set.
The post_filter is applied to the search hits at the very end of a search request, after aggregations have already been calculated.
In version 5.2, filtered query is replaced by the bool query, and returns error on my Elastic 5.2 instance. See here.
The new syntax is:
{
"query":{
"bool":{
"must":{
"query_string":{
"query":"Declared"
}
},
"filter":{
"term":{
"language_id":10
}
}
}
}
}
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