0

I am trying to execute a term query as

get indexName/test/_search
{
  "query": {
  "term": {
      "stat": "REVIEW" 
    }
  }
}

but it returns everything i.e. all the records. Plus when i try to execute the same query in python using the elasticsearch api as

    print qry
    result =  es.search(index=indexName, body=qry)

    total = result['hits'] ['total']
    print "Got "+str(total)

i get

{'query': {'term': {'stat': 'REVIEW'}}, 'from': 0}
Got 0

how is this possible? Is there something wrong with my syntax?

AbtPst
  • 7,778
  • 17
  • 91
  • 172
  • 2
    Always [use POST](http://stackoverflow.com/questions/34795053/es-keeps-returning-every-document/34796014#34796014) when sending a payload ;-) If you send `{'query': {'term': {'stat': 'review'}}, 'from': 0}` you'll probably get some hits – Val Feb 16 '16 at 17:36
  • i tried post indexName/test/_search { "query": { "term": { "stat": "REVIEW" } } } but i got 0 hits – AbtPst Feb 16 '16 at 19:34
  • 1
    Please read my above comment again and use the exact same query, i.e. with lowercase `review` :-) – Val Feb 16 '16 at 19:44
  • hey, that worked! but my data is not lowercase!!! – AbtPst Feb 16 '16 at 19:57
  • 1
    Congrats! It is lowercased by ES and then indexed in lowercase, but what you see in the source is what you have indexed and that doesn't change. – Val Feb 16 '16 at 21:09

0 Answers0