W
W
wtpltd2019-12-23 02:33:03
elasticsearch
wtpltd, 2019-12-23 02:33:03

How are AND, OR, NOT implemented in Elasticsearch?

There are products that are discontinued and you can buy them only from existing stocks. For example, the document can be simplified to
```json
{
"archived": true,
"total": 10
}
```
Elastic 7.5 How to build a query to select all products other than those with "archived": true AND "total" ": != 0? Somewhere I don’t catch up on how to correctly resolve AND, OR, NOT nesting Boolean Query.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alisher E., 2020-10-03
@ALiSHERBE

Hi, basically
should is or,
must is and.

[query] => Array
(
    [bool] => Array
        (
            [should] => Array
                (
                    [0] => Array
                        (
                            [bool] => Array
                                (
                                    [must] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [match] => Array
                                                        (
                                                            [values.attribute] => 15
                                                        )
                                                )
                                            [1] => Array
                                                (
                                                    [match] => Array
                                                        (
                                                            [values.value_string] => 64
                                                        )
                                                )
                                        )
                                )
                        )
                    [1] => Array
                        (
                            [bool] => Array
                                (
                                    [must] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [match] => Array
                                                        (
                                                            [values.attribute] => 15
                                                        )
                                                )
                                            [1] => Array
                                                (
                                                    [match] => Array
                                                        (
                                                            [values.value_string] => 32
                                                        )
                                                )
                                        )
                                )
                        )
                )
        )
)

Read more on stackoverflow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question