can't get partial word search to work with haystack/elasticsearch -


I'm trying to work partial word and I've already seen but for some reason I do not have setup work. I am using a heap of elastic search with somebody can tell me what I am doing wrong.

VendorIndex (indexes.SearchIndex, indexes.Indexable): text = indexes. EdgeNgramField (document = true, use_template = true) company_name = indexed. CHFIFF (model_tar = 'company_name', null = true) def get_model (self): back seller def index_queryset (using self, = none): "" "When the whole index is updated for the model . " .get_model (). Objects.all ()

EDIT: I have done this work using AutoComplete. However, I think this is a hack. But here's my code:

  class VendorIndex (indexes.SearchIndex, indexes.Indexable): text = indexes.CharField (document = true, use_template = true) company_name = indexes.CharField (model_attr = Get_model (self): return seller def index_queryset (self, using = none): "" "when the entire index for the model Is used to update. "" "Return to self .get_model (). Objects.all ()  

In the scene then:

  class SearchVendorView (generics.ListAPIView): serializer_class = serializers.CustomerVendorSerializer def get_queryset (self):. Results = SearchQuerySet () Model (vendor) .autocomplete (company_name_auto = self.request.GET.get ('Q', '')) vendors = [] resultor.object result for seller [result]: vendor.is_liked = Vendor .objects.from_request (self.request) .get (pk = vendor.id) .user_vote v Endors.append return vendors  

In my case: django-Haystack == 2.5.1 + elasticsearch == 5.0.1 + Java elastic search daemon v2.3.1 is sufficient to obtain partial search:

import author class AuthorIndex (indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField (document = true, use_template = true) last_name = indexes.CharField (model_attr = 'last_name') first_name = Indexes.CharField (model_attr = 'first_name') def get_model (self): return author def index_queryset (using itself, using = none): "" "Used when the entire index for the model has been updated. Return "auto" get_model (). Objects.all ()

and then Python manage.py rebuild_index and you can be searched by:

P> div>

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -