से completion suggester
का उपयोग करके elasticsearch सूचकांक में डेटा अनुक्रमित के बाद से पर उल्लेख इस्तेमाल किया संस्करण 5:
_suggest endpoint पक्ष में पदावनत कर दिया गया है _search endpoint के माध्यम से सुझाव का उपयोग करने के लिए। 5.0 में, _search endpoint को केवल खोज अनुरोधों के सुझाव के लिए अनुकूलित किया गया है।
(https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-suggesters.html से)
बेहतर तरीका यह है suggest
विकल्प के साथ खोज API का उपयोग कर रहा है
from elasticsearch import Elasticsearch
es = Elasticsearch()
text = 'ra'
suggest_dictionary = {"my-entity-suggest" : {
'text' : text,
"completion" : {
"field" : "suggest"
}
}
}
query_dictionary = {'suggest' : suggest_dictionary}
res = es.search(
index='auto_sugg',
doc_type='entity',
body=query_dictionary)
print(res)
सुनिश्चित करें कि आप suggest
क्षेत्र के साथ प्रत्येक दस्तावेज़ अनुक्रमित है
sample_entity= {
'id' : 'test123',
'name': 'Ramtin Seraj',
'title' : 'XYZ',
"suggest" : {
"input": [ 'Ramtin', 'Seraj', 'XYZ'],
"output": "Ramtin Seraj",
"weight" : 34 # a prior weight
}
}
नहीं
स्रोत
2016-04-05 22:19:26
सुनिश्चित करें कि यह संभव है, खुले मुद्दे हैं [यहां] (https://github.com/aparo/pyes/issues/334) और [ यहां] (https://github.com/aparo/pyes/issues/387) इसके लिए। –