0

I have the following working query, using CURL:

  curl -X GET 'http://myhost/myindex/_search?q=text:%7B1933%20TO%201949%7D'

which identifies all documents inside the index myindex which in the text field (string type) contains mentions of dates between 1933 and 1949. I would like to use this query programatically from Python, and in this sense I have the Python ElasticSearch client installed, Pyes:

  from elasticsearch import ElasticSearch
  from pyes import *

and then I would like to call

  es = ElasticSearch('myhost')
  totalDocs = es.search('myindex', body={'query':{'query_string':{'query': 'text:%7B1933%20TO%201949%7D'}},"size":0})['hits']['total']

but this syntax is not working. Also it is important that I look into the text field only for these date mentions. Are there any ways to use the initial query in Python? Many thanks!

Later edit: I have also tried it like this:

  totalDocs = es.search('myindex', 'text:%7B1933%20TO%201949%7D')['hits']['total']

It works, but it returns no documents at all.

Actually my question resumes to this question: [ElasticSearch - specify range for a string field

Crista23
  • 3,203
  • 9
  • 47
  • 60

0 Answers0