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!

Soundarya Thiagarajan
  • 574
  • 2
  • 13
  • 31
  • Which is the correct result? What do you expect and what do you get? – davide Sep 20 '16 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. – Soundarya Thiagarajan Sep 20 '16 at 11:21
  • 1
    maybe use "pa" and not "PA". but yes, what are you trying to get here ? – blackmamba Sep 20 '16 at 11:22
  • 1
    Possible duplicate of [ElasticSearch not returning results for terms query against string property](http://stackoverflow.com/questions/21933787/elasticsearch-not-returning-results-for-terms-query-against-string-property) – davide Sep 20 '16 at 11:33

1 Answers1

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

Community
  • 1
  • 1
blackmamba
  • 556
  • 3
  • 11