pyes icon indicating copy to clipboard operation
pyes copied to clipboard

Pythonic way to access to suggest?

Open nopper opened this issue 12 years ago • 1 comments

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?

nopper avatar Oct 02 '13 13:10 nopper

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.

alastair avatar Oct 09 '13 22:10 alastair