django-haystack

Using django-haystack, how do I order results by content type

十年热恋 提交于 2019-12-07 09:07:00
问题 I'm using django-haystack for a search page on my site, and I want to order all the results by their content type. Is there a way I can do that? To make it simpler, suppose I have a single application and several classes. Thanks in advance 回答1: from How to order search results by Model: You can do SearchQuerySet().order_by('django_ct') . As a warning, this throws out relevancy. The only way to keep relevancy & group by model is either to run many queries (one per model - usually performant

Solr authentication (using Django Haystack)

寵の児 提交于 2019-12-07 07:08:27
My solr service works without HTTP authentication, but my webhost provides it and I'd like to take advantage of it. I've been given a username and password to access my solr service by dotcloud in the form of a url: 'http://dotcloud:XXXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/' When I point my browser to this address, it works just fine. In my settings.py file I have the following line: HAYSTACK_SOLR_URL = 'http://dotcloud:XXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/' but when I run ./manage.py build_solr_schema, I get the following error: ValueError: invalid

Django Haystack faceting on the model type

本秂侑毒 提交于 2019-12-07 05:09:34
问题 I want to facet the results based on the different model_names (classes) returned. Is there an easy way to do this? 回答1: Have you tried adding a SearchIndex field with this information? E.g. class NoteIndex(SearchIndex, indexes.Indexable): title = CharField(model_attr='title') facet_model_name = CharField(faceted=True) def get_model(self): return Note def prepare_facet_model_name(self, obj): return "note" class MemoIndex(SearchIndex, indexes.Indexable): title = CharField(model_attr='title')

Django-Haystack: 'NoneType' object has no attribute '_default_manager'

六眼飞鱼酱① 提交于 2019-12-07 04:56:22
问题 I am trying to add a haystack search to my base.html to include it globally on my site. It errors though when i submit a search I am getting: Django-Haystack: 'NoneType' object has no attribute '_default_manager' I have added it to INSTALLED_APPS and my urls.py. ./manage.py rebuild_index runs fine. models.py: class Site(models.Model): site_name = models.CharField(max_length=100, blank=False, null=False) site_manager = models.CharField(max_length=100, blank=False, null=False) address_1 =

Can't use django management commands because of Import Errors when haystack tries to import multiligualmodel

会有一股神秘感。 提交于 2019-12-07 04:11:24
I'm using django-haystack for searching on my site. I'm also using django multilingual model for I18n. I import MultilingualModel in search_indexes.py I ca run all manangement commands as long as I don't have haystack in the INSTALLED_APPS. When haystack is in the INSTALLED_APPS and try to run syncdb or migrate (and several other management commands) I'm always getting: django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name MultilingualModel This is likely related to the hacks done in haystack.autodiscover() . This behavior is documented here: http://docs

Django/Haystack error: elasticsearch.exceptions.RequestError: TransportError(400, 'parsing_exception',…)

半城伤御伤魂 提交于 2019-12-07 01:26:12
问题 I am using elasticsearch as backend for haystack in my Django project. I created everything required for a search as mentioned here. But when i search i throws a traceback error with TransportError(400, 'parsing_exception', 'no [query] registered for [filtered]'). I have googled for this issue. But don't get any solution. I would appreciate helping me solve this. My traceback: Traceback (most recent call last): File "c:\python34\lib\site- packages\haystack\backends\elasticsearch_backend.py",

Django-Haystack giving attribute error?

心不动则不痛 提交于 2019-12-07 00:50:15
问题 I am trying to use Haystack and Whoosh with my Django app. I followed the steps on Haystack docs, but i am getting this error when i do a search AttributeError at /search/ 'module' object has no attribute 'get_model' search_indexes.py - import datetime from haystack import indexes from movies.models import Movie class MovieIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) title = indexes.CharField(model_attr='title') def get_model(self):

remote autocomplete by typeahead works only on unique queries

 ̄綄美尐妖づ 提交于 2019-12-06 14:54:30
问题 I am having problem setting up typeahead with bloodhound on two fields - symbol and name. You can try live version on my DGI portfolio manager and autocomplete remote source here. Typeahead sometimes works and sometimes it does not. If I type symbols like "jnj", "mcd", "aapl" it works. However, when I type string from name like "corporation" and "inc" that have around 3000 objects with this name, it does not work. I doubt it is because it is loading, since json file is served quickly(under

Haystack Not Returning Results that Solr Admin Console Highlights

自古美人都是妖i 提交于 2019-12-06 14:17:44
问题 I've recently set up solr and haystack to search one of my django models. I attempted to modify the default solr schema built by haystack to use the NGramTokenizerFactory : <fieldType name="text" class="solr.TextField"> <analyzer type="index"> <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="32" /> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="32" /> <filter

Main field name (document=True)

时间秒杀一切 提交于 2019-12-06 12:28:48
问题 Django Haystack docs say: **Warning** When you choose a document=True field, it should be consistently named across all of your SearchIndex classes to avoid confusing the backend. The convention is to name this field text. There is nothing special about the text field name used in all of the examples. It could be anything; you could call it pink_polka_dot and it won’t matter. It’s simply a convention to call it text. But I don't get what it means. This is their example model: import datetime