aparo / pyes

Python connector for ElasticSearch - the pythonic way to use ElasticSearch
BSD 3-Clause "New" or "Revised" License
607 stars 270 forks source link

Pythonic way to access to suggest? #334

Open nopper opened 11 years ago

nopper commented 11 years ago

Is there a way to access to suggest feature of elasticsearch?

I have tried to use pyes.query.Suggest with no luck. Of course I got several error and inconcistencies in the code, such as the use of not defined method, class hierarchy breakages and so on.

  File "/Users/nopper/.pythonbrew/venvs/Python-2.7.3/frugal/lib/python2.7/site-packages/pyes/es.py", line 1396, in suggest
    suggest.add_field(text, name=name, field=field, size=size)
AttributeError: 'Suggest' object has no attribute 'add_field'
  File "/Users/nopper/.pythonbrew/venvs/Python-2.7.3/frugal/lib/python2.7/site-packages/pyes/es.py", line 1377, in suggest_from_object
    indices = self.validate_indices(indices)
AttributeError: 'ES' object has no attribute 'validate_indices'
  File "/Users/nopper/.pythonbrew/venvs/Python-2.7.3/frugal/lib/python2.7/site-packages/pyes/es.py", line 1387, in suggest_from_object
    return expand_suggest_text(result)
NameError: global name 'expand_suggest_text' is not defined

Is it at least possible to just inject a raw JSON request as is without any validation so I can temporary bypass this error?

alastair commented 11 years ago

I ran into this a few weeks ago too. I added some comments at https://github.com/aparo/pyes/commit/c697a7f137e3aef035c3886554695a3a618d64f2, but got to the same point that you did with missing expand_suggest_text.