Can't achieve autocomplete
See original GitHub issueHello, I am struggling with autocomplete for a long time. Simply i am loading list of cities to the elasticsearch, i am printing first index so i am sure that Novinki city exists there. And when I do the execute suggest I receive no completion for text “Novin”. I was refering to official tutorial - http://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html Can someone give me a tip what I am doing wrong? Thank you
import json
from elasticsearch_dsl import Search, Index, DocType, Text, Completion
from elasticsearch_dsl.connections import connections
connections.create_connection(hosts=['localhost'])
with open('city_list.json') as json_data:
cities_json = json.load(json_data)
cities = Index('cities')
cities.delete(ignore=404)
cities.create()
@cities.doc_type
class City(DocType):
name = Text()
name_suggest = Completion()
country = Text()
class Meta:
doc_type = 'city'
City.init()
for index, city in enumerate(cities_json['cities']):
if index == 1:
print(city) # this prints {'coord': {'lon': 37.666668, 'lat': 55.683334}, 'name': 'Novinki', 'id': 519188, 'country': 'RU'}
city = City(name=city['name'], country=city['country'])
city.save()
s = City.search()
s = s.suggest('name_suggestions', 'Novin', completion={'field': 'name_suggest'})
suggestions = s.execute_suggest()
for result in suggestions.name_suggestions:
print('Suggestions for %s:' % result) # this gives me Suggestions for {'length': 5, 'options': [], 'offset': 0, 'text': 'Novin'}:
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
AutoComplete not working correctly - Outlook - Microsoft Learn
Check to see if AutoComplete is turned on · In Outlook, select File > Options. · Select the Mail tab. · Scroll roughly...
Read more >jquery - Can't get $(this) working in jQueryUI autocomplete
Show activity on this post. I'm trying to create a generic autocomplete script using jQueryUI. The autocomplete should work for every: <input type='text'...
Read more >Manage Google autocomplete predictions - Google Search Help
Learn more about autocomplete. Turn off Personal results. Important: When Personal results are off, you won't get personalized predictions or recommendations ...
Read more >Can't get Autocomplete to work [#3088539] | Drupal.org
Hi,. I have followed the steps in the Readme, and my full text search field is has to correct attributes (I guess). However,...
Read more >Can't get autocomplete for dependencies · Issue #27 - GitHub
I am using swift package (SPM) with dependencies such as PerfectHTTPServer. is there any configuration I need to do to make autocomplete work?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @HonzaKral ,
I tried to use the analyzer argument in the Completion class, but it fails like one of the comments above:
This is my code:
I’ve debugged the code and I fixed it adding the
_param_defs
in the Completion classI don’t know if it is the best approach, but with some guidance I can open a PR.
PS: the
elasticsearch-dsl-py
version is6.2.1
My bad, please use: