0

I have downloaded a sample accounts json database from the elasticsearch website.https://www.elastic.co/guide/en/elasticsearch/reference/current/_exploring_your_data.html

I am trying to do some queries on top of it.

For example,

curl -XGET 'http://localhost:9200/bank/account/_count?pretty' -d '{
    "query":{
    "filtered":{
    "filter":{
    "bool":{
    "should":[{"term":{"gender":"M"}},{"term":{"age":35}}]
    }
    }
    }
    }
    }'

getting the output for this correctly with the count.

But If I try like the query below, I am not getting the correct result.

curl -XGET 'http://localhost:9200/bank/account/_count?pretty' -d '{
"query":{
"filtered":{
"filter":{
"bool":{                        
"should":[{"term":{"gender":"F"}},{"term":{"state":"PA"}}]
}             
}               
}                    
}      
}'

I am not getting the correct result.. Is there anything wrong in the query syntax or the way of using it?

Can anyone help here!

4
  • Which is the correct result? What do you expect and what do you get? Commented Sep 20, 2016 at 11:20
  • for example with the gender F and state PA there are results. but still im getting the count as 0. but for the first query, im getting it correctly. Commented Sep 20, 2016 at 11:21
  • 1
    maybe use "pa" and not "PA". but yes, what are you trying to get here ? Commented Sep 20, 2016 at 11:22
  • 1
    Possible duplicate of ElasticSearch not returning results for terms query against string property Commented Sep 20, 2016 at 11:33

1 Answer 1

1

Use lowercase while searching

eg- f not F
    pa not PA

read this for better understanding ElasticSearch not returning results for terms query against string property

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.