Devon
Devon

Reputation: 335

How do I use OR in a elasticsearch query?

I'm having an issue with this command. I want to combine both values into one output.

curl -s 'server.domain.com:3600/sybok-sdk-'2017.01.13'/_count?q=os:"iPhone%20OS"OR"iOS"' | jq '.count'

In this command, its only returning the iPhone%20OS results.

Thank you Devon

Upvotes: 1

Views: 47

Answers (2)

Kulasangar
Kulasangar

Reputation: 9434

What if you have the OR condition in between the + signs:

curl -s 'server.domain.com:3600/sybok-sdk-'2017.01.13'/_count?q=os:"iPhone%20OS"+OR+"iOS"' | jq '.count'

OR

curl -s 'server.domain.com:3600/sybok-sdk-'2017.01.13'/_count?q=os:"iPhone%20OS"OR"iOS"' | jq '.count'

You might want to have a look at this, hope it helps!

Upvotes: 1

cn0047
cn0047

Reputation: 17051

Accordingly to this doc you have to do next:

curl -s 'server.domain.com:3600/sybok-sdk-'2017.01.13'/_count?q=os:("iPhone%20OS" "iOS")' | jq '.count'

Upvotes: 0

Related Questions