Haystack - Search for Django

2019-03-27 01:07|来源: 网路

Haystack - Search for Django

Search doesn't have to be hard. Haystack lets you write your search
code once and choose the search engine you want it to run on. With a
familiar API that should make any Djangonaut feel right at home and
an architecture that allows you to swap things in and out as you need
to, it's how search ought to be.
Haystack is
BSD licensed,
plays nicely with third-party apps without needing to modify the
source and supports Solr,
Elasticsearch,
Whoosh and
Xapian.

Get started

  1. Install the package:

     

    1. Latest stable (1.2.6) off PyPI: pip install django-haystack
    2. Latest dev (2.0.0-beta) off GitHub: pip install -e git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
  2. Add haystack to your INSTALLED_APPS.
  3. Create search_indexes.py files for your models.
  4. Setup the main SearchIndex via autodiscover.
  5. Include haystack.urls to your URLconf.
  6. Search!

转自:http://www.cnblogs.com/lexus/archive/2012/06/07/2540942

相关问答

更多
  • 无需分叉Haystack,您可以在自己的后端更新该方法(有关更多详细信息,请参阅伸展Haystack的ElasticSearch后端 )。 build_search_kwargs方法返回一个字典,因此您可以修改原始返回值。 免责声明:此代码仅仅是您如何更新自己的后端的示例, 而不是如何实现模糊搜索。 class FuzzyBackend(ElasticsearchSearchBackend): def build_search_kwargs(self, query_string, **kwargs) ...
  • 答案在这里: https : //github.com/toastdriven/django-haystack/pull/720 请求已准备就绪,但仍未合并:它缺少文档和测试。 An answer is here: https://github.com/toastdriven/django-haystack/pull/720 Request is ready, but still not merged: it lacks docs and tests.
  • 好的,问题似乎并不清楚,我的意思是我想将关键字sub_category添加到值列表中的字典conds中。 所以我发现这种方式可以回答上面的问题: conds['sub_categary__in'] = sub_category_list OK, the question seem to not clearly, I meant I want to add the key sub_category into the dictionary conds that values are list. So i f ...
  • 好吧,我终于弄明白了。 我基本上不得不为我的SearchForm的html添加第二个提交按钮,然后使用javascript将操作重定向到我的“search_export”视图。 由于在提交表单时不会传递构面,因此我必须从请求中获取构面(在搜索页面模板中)并将其传递给相当虚伪的URL。 然后必须在视图中重新评估构面。 我将在下面粘贴所有代码: search.html {% block content %}