Elasticsearch query string query with not equal to?

Elasticsearch query string query with not equal to?

You need to use the NOT operator, like this:

n

!(name:Fred)n

n

or

n

NOT (name:Fred)n

You should use bool query with must_not statement

n

{n  query: {n    bool : {n      must_not : {n        term : {n          name : Fredn        }n      }n    }n  }n}n

Elasticsearch query string query with not equal to?

You can also use a combination of must and must_not. Like pull docs where name is Ajit and status is not queued.

n

{n    query: {n        bool: {n            must: [n                {n                    match: {n                        name: Ajitn                    }n                }n            ],n            must_not: [n                {n                    match: {n                        status: queuedn                    }n                }n            ]n        }n    }n}n

Leave a Reply

Your email address will not be published.