Reputation: 488
DSL query is below
{'from': 0, 'size': 10, 'aggs':
{'products': {'terms': {'field': 'softwares.name.keyword', 'order': {'_key': 'desc'}}},
'color': {'terms': {'field': 'white.name.keyword', 'order': {'_key': 'desc'}}},
'types': {'terms': {'field': 'mercedez.name.keyword', 'order': {'_key': 'desc'}}}},
'query': {'bool': {'must': {'match_all': {}},
'filter': [{'term': {'name.keyword': 'Germany'}}]}}}
'filter': [{'term': {'name.keyword': 'Germany'}
My Ask?
filter not
Upvotes: 0
Views: 1989
Reputation: 5486
You can use must_not query with bool query.
Option 1: using filter
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": [
{
"bool": {
"must_not": [
{
"term": {
"name.keyword": {
"value": "Germany"
}
}
}
]
}
}
]
}
}
}
Option 2: without filter (but here Germany query will be also consider for score calculation)
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"must_not": [
{
"term": {
"name.keyword": {
"value": "Germany"
}
}
}
]
}
}
}
Upvotes: 1