аватар question@mail.ru · 01.01.1970 03:00

Search by entering the line in Django + Haystack + Whoosh

There is a certain model. It stores the names of films. Here is the index class:

   from  haystack  impport  indexes  from  kino.films.models  import  films  class   Filmsindex  (indexes.Searchindex, indexes.indexable):  text = indexes.charfield (docharfield =  true , use_template =  true )  rusname = indexes.charfield (model_attr =  'osname' )  Origname = Indexes.Charfield (Model_attr =  'origname' )  year = indexes.integerfield (model_attr =  '"year' )   Def   get_model  ( self ):   retu  file 

index of index. Created and everything almost works, but not quite as it is necessary. Request of the species

  SearchquerySet (). class = ""> '' avatar ')     

Retus what you need, and the species

  Filter  (Content =  '"avat' )     

does not retu anything. What am I doing wrong?

аватар answer@mail.ru · 01.01.1970 03:00

Nothing. More precisely, you do everything right. He himself stuck on this when he did an autocompplet through the hiSTEC in the search. Whoosh is just a “full -text” “search with minimal morphology. To search for entry, you need to use the classic Like.

update I repent, I deceive you. Still decided to google, so as not to hit the mud in the mud. And this is what was found. Highstack has a special method of autocomplete just for this.

   Import  Datetime  from  haystack  Import  indexes  from  myapp.models  Import  note  class   noteindex  (indexes.searchindex, indexes.indexable):  text = Indexes.Charfield (Document =  true , use_template =  true )  author = indexes.charfield (model_attr =  'user' )  pub_date = indexes.datetimefield (model_attr =  'pub_date' )  # we add this for autocompplete.   Content_auto = indexes.edgengramfield (Model_attr =  'content' )   def   get_model  ( self ):   retu  note  def   index_Queryset  ( self ):     retu  noote.objects.  Filter  (pub_date__lte = datetime.dateetime.now ())     

and the search itself

   from  haystack.query  import  SearchquerySetsetsearchquerySet (). Autocomplete (control_auto = )  # Result Match Things Like 'Goldfish', 'Cuckold' & amp; 'Older'                                    

Latest

Similar