I'm writing a Java application and use elastic search as database.
I'm looking for a way to write a "not-contains" query.
For Example I've got a field category with values:
- Car
- Bus
- Train
- Fastcar
Now I want to get all entries which not contains "fast" in their category.
How can I build a query like this? I have been looking around here but can't find anything.
Thanks in advance
So thanks to @James and @Bhavya Gupta I could update my query but it doesn't work as expected.
My query now is:
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"bool": {
"must_not": [
{
"term": {
"BetriebsID": "Aufzug"
}
} ]
}
}
}
}
But the result still contains hits like this:
"hits": [
"_source": {
...
"FormNo": 9150520000000692,
"CreatedTime": "2020-05-15T08:19:03.000Z",
"templateId": "Aufzugsstoerung",
"SYS_FORM_ID": "150520_000000692",
"trecId": 151,
"BetriebsID": "20200515_1019_Aufzugsstoerung",
"displayName": "Aufzugsstörung",
...
}
}]
I also tried it with the wildcard query from James, with the same result.