django-haystack

Haystack+ES解决搜索服务

半城伤御伤魂 提交于 2020-04-13 11:40:08
【今日推荐】:为什么一到面试就懵逼!>>>   最近项目组需要对老的搜索项目进行迁移和改造,刚入职2个星期的我光荣的接受了这份工作,这也是我第一次接触Haystack和Elasticsearch,以下是记录下工作中的一些需求解决,具体haystack的玩法大家可以看查看官方文档: https://django-haystack.readthedocs.io/en/master/ ,查看本文默认你已经基本了解了haystack的使用,包括基本的配置和使用 在开始 之前,我还是有必要灌输几个概念:什么是ES,什么是Haystack,两者关系。 1.什么是ES? 在本文你只需要知道它是一个搜索服务器,存放着我们需要被搜索的数据,存储结构类似于我们的数据库,也可以对其记录进行curd的操作,重要的是能够进行‘分词’,同样是建立索引,数据库则需要把整个一句话作为索引,然后才能通过查询这一句话才能使用索引找到该记录,而ES通过‘分词’建立索引,可以建立多个单词索引指向同一记录,我们可以简单的键入一两个关键字就能调用索引弹出相关的信息,当然如果数据量少,就没必要使用ES了,毕竟这种情况下使用模糊查询也慢不了多少。 2.什么是Haystack? Haystack 是以django的一个应用库,主要用来整合市场是的几大搜索后端作为django对它们操作的统一入口。   3.两者关系?  

ignore accents in elastic search with haystack

空扰寡人 提交于 2020-01-14 02:34:51
问题 I am using elasticsearch along with haystack in order to provide search. I want user to search in language other than english. E.g. currently trying with Greek. How can I ignore the accents while searching for anything. E.g. let's say if I enter Ανδρέας ( with accents), its returning results matched with it. But when I enter Ανδρεας, its not returning any results. The search engine should bring any results that have "Ανδρέας" but also "Ανδρεας" as well (the second one is not accented). Can

ignore accents in elastic search with haystack

大憨熊 提交于 2020-01-14 02:34:00
问题 I am using elasticsearch along with haystack in order to provide search. I want user to search in language other than english. E.g. currently trying with Greek. How can I ignore the accents while searching for anything. E.g. let's say if I enter Ανδρέας ( with accents), its returning results matched with it. But when I enter Ανδρεας, its not returning any results. The search engine should bring any results that have "Ανδρέας" but also "Ανδρεας" as well (the second one is not accented). Can

Ordering Solr search result by day/week/month/year views

廉价感情. 提交于 2020-01-13 19:09:17
问题 Have Video model and search index for it. Django-haystack and Solr are used. It is needed to sort result by video's views for day/week/month/year. Is it possible to this without always updating of search index by information of views for last day/week/month/year? If need only sort by view for day and total, then it can be possible update index only for videos viewed for one day, which have current views equal 0. Using update_index every few hours looks like not good idea, because now it takes

Ordering Solr search result by day/week/month/year views

橙三吉。 提交于 2020-01-13 19:08:16
问题 Have Video model and search index for it. Django-haystack and Solr are used. It is needed to sort result by video's views for day/week/month/year. Is it possible to this without always updating of search index by information of views for last day/week/month/year? If need only sort by view for day and total, then it can be possible update index only for videos viewed for one day, which have current views equal 0. Using update_index every few hours looks like not good idea, because now it takes

django haystack custom form

余生颓废 提交于 2020-01-13 10:43:50
问题 I'm trying to make a custom search form using django haystack, i just modify from haystack's documentation : forms.py from django import forms from haystack.forms import SearchForm class DateRangeSearchForm(SearchForm): start_date = forms.DateField(required=False) end_date = forms.DateField(required=False) def search(self): # First, store the SearchQuerySet received from other processing. sqs = super(DateRangeSearchForm, self).search() # Check to see if a start_date was chosen. if self

django haystack custom form

帅比萌擦擦* 提交于 2020-01-13 10:43:20
问题 I'm trying to make a custom search form using django haystack, i just modify from haystack's documentation : forms.py from django import forms from haystack.forms import SearchForm class DateRangeSearchForm(SearchForm): start_date = forms.DateField(required=False) end_date = forms.DateField(required=False) def search(self): # First, store the SearchQuerySet received from other processing. sqs = super(DateRangeSearchForm, self).search() # Check to see if a start_date was chosen. if self

django haystack custom form

邮差的信 提交于 2020-01-13 10:43:06
问题 I'm trying to make a custom search form using django haystack, i just modify from haystack's documentation : forms.py from django import forms from haystack.forms import SearchForm class DateRangeSearchForm(SearchForm): start_date = forms.DateField(required=False) end_date = forms.DateField(required=False) def search(self): # First, store the SearchQuerySet received from other processing. sqs = super(DateRangeSearchForm, self).search() # Check to see if a start_date was chosen. if self

ElasticSearch: EdgeNgrams and Numbers

孤者浪人 提交于 2020-01-10 04:03:07
问题 Any ideas on how EdgeNgram treats numbers? I'm running haystack with an ElasticSearch backend. I created an indexed field of type EdgeNgram. This field will contain a string that may contain words as well as numbers. When I run a search against this field using a partial word, it works how it's supposed to. But if I put in a partial number, I'm not getting the result that I want. Example: I search for the indexed field "EdgeNgram 12323" by typing "edgen" and I'll get the index returned to me.

Haystack indexing related model issue

血红的双手。 提交于 2020-01-07 00:07:51
问题 I want to prepare an index for two models, so I can search text from both models. Below is my code. When I run "python manage.py rebuild_index" I get the error "raise self.related.model.DoesNotExist" for the index line "return obj.mainparts.parts". models.py class Main(models.Model): ....#various fields class Parts(models.Model): main = models.OneToOneField(Main, primary_key=True, related_name='mainparts') parts = models.TextField(blank=True) search_indexes.py class MainIndex(indexes