Text Search across fields via body Dict


(Ayush Rastogi) #1

Hi All,

I am new to ES.
I have a index( book type ) which stores questions and answers.
I want to search text present either question or in answer.
I can do it via curl in this fashion,

curl -i XGET 'http://localhost:9200/test-rule1/_search?q=string'

But I am not sure to to achive this via the body dict used in search method in the python API query DSL

I assume the body should be something similar to,

inputbody ={"query": { "match_all": { searchStr }  } }

What should be the key against the searchStr such that it the search is independent of fields.

Thanks
Ayush.


(Ayush Rastogi) #2

The key is "_all", example

inputbody ={"query": { "_all": { searchStr }  } }

(system) #3