Marco Wagner
Marco Wagner

Reputation: 441

Using Elasticsearch REST API with Browser: how to do AND operation

I want to know how can I search for 2 key:value pairs with the browser on localhost:9200

For Example: want to combine country=CAN AND brand=V

_source": {

    "country": "CAN",
    "brand": "V",
    "leadID": 10333,
    "datetime": 1442247315000

}
... and so on

I tried this uri with the "default_operator" set to AND:

http://localhost:9200/_search?default_operator=AND&q=country:CAN&q=brand:V

In the response I got country=CAN with brand=V, but I also got country=PRT with brand=V. So it did an OR operation instead of AND operation.

Upvotes: 0

Views: 181

Answers (1)

Andrei Stefan
Andrei Stefan

Reputation: 52368

Try this http://localhost:9200/_search?default_operator=AND&q=country:CAN AND brand:V

Your browser will translate it to http://localhost:9200/_search?default_operator=AND&q=country:CAN%20AND%20brand:V

meaning you combine the two conditions into one: q=country:CAN AND brand:V.

Upvotes: 1

Related Questions