django-haystack

Django-Haystack returns no results in search form

自闭症网瘾萝莉.ら 提交于 2019-12-08 06:19:53
问题 I am using Django-Haystack with Whoosh backend. When I do a query I get no results. I tried the debugging steps suggested in the Haystack docs by typing the following into a Django shell, and I can see that all the text I want has been indexed. from haystack.query import SearchQuerySet sqs = SearchQuerySet().all() sqs.count() sqs[0].text My search.html page has the following section (copied straight from the documentation): {% for result in page.object_list %} <p> <a href="{{ result.object

set field's initial value within haystack's FacetedSearchForm

旧巷老猫 提交于 2019-12-08 05:42:12
问题 I am using django-haystack with Solr backend in one of my projects. I have a SearchForm which inherits from FacetedSearchForm . Now, what I am trying to do is to add an intital value to some of the fields within the Form. from django.forms import forms from haystack.forms import FacetedSearchForm MySearchForm(FacetedSearchForm): """ My basic search form """ field_one = forms.CharField(required=False, initial='0') field_two = forms.CharField(required=False, initial='some_value') previously

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

不羁岁月 提交于 2019-12-08 04:26:07
问题 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 回答1: This is likely

Haystack: one searchIndex for multiple models

懵懂的女人 提交于 2019-12-08 01:16:30
问题 On the getting started page of Haystack, it describes the possibility of using one SearchIndex for multple models: You generally create a unique SearchIndex for each type of Model you wish to index, though you can reuse the same SearchIndex between different models if you take care in doing so and your field names are very standardized. However I haven't found any information regarding how to do so. The reasoning behind it is that a few Heroku search engine apps provide limited amount of

Django Haystack Faceting examples

百般思念 提交于 2019-12-07 21:26:45
问题 I want to use Django-Haystack-Solr in a site I am working on. I have worked through the examples in the Haystack documentation and have searched the internet extensively for other examples. I am having difficulty making the leap to integrating it in my site. I found http://www.slideshare.net/Nagyman/faceted-navigation-using-django-haystack-and-solr interesting, but fell short of how to pull it all together. If anyone has run across some "robust" Haystack faceting examples, websites that are

How to get n search objects from a SearchQuerySet without changing the type?

匆匆过客 提交于 2019-12-07 18:10:31
I am trying to get the to 10 objects like : q_auth = SearchQuerySet().filter(content=validate_query) q_auth = q_auth[:10] print type(q_auth) The output I want is: <class 'haystack.query.SearchQuerySet'> but I am getting is <type 'list'> . Can some one please help me out? I tried something similar like your code but got the output like this: <class 'django.db.models.query.QuerySet'> Based on what you've got, I think you can try something like: print type(q_auth[0]) Looking at the source , you will see that q_auth[:10] returns a list of results. A SearchQuerySet is lazy and might not have all

Django 1.9/Haystack 2.4.1 “Model could not be found for SearchResult”

自古美人都是妖i 提交于 2019-12-07 17:58:39
Let me just first say, I have tried the fixes here: Haystack says “Model could not be found for SearchResult” and I'm still getting Model could not be found for SearchResult '<SearchResult: dictionary.termentry (pk=u'10')>'. I'm on Django 1.9 & Haystack 2.4.1 with Whoosh. I've determined that the SearchQuerySet is filtering just fine (when I print queryset I get a list of SearchResult objects). I didn't touch anything beyond the SearchIndex definitions, so this is out-of-the-box stuff. Just for reference, here's the relevant bits of code: in search_indexes.py: class TermIndex(indexes

set field's initial value within haystack's FacetedSearchForm

雨燕双飞 提交于 2019-12-07 14:18:33
I am using django-haystack with Solr backend in one of my projects. I have a SearchForm which inherits from FacetedSearchForm . Now, what I am trying to do is to add an intital value to some of the fields within the Form. from django.forms import forms from haystack.forms import FacetedSearchForm MySearchForm(FacetedSearchForm): """ My basic search form """ field_one = forms.CharField(required=False, initial='0') field_two = forms.CharField(required=False, initial='some_value') previously when i was using django.forms.Form this used to work absolutely fine. I have been digging around django

Haystack whoosh models() not narrowing models

独自空忆成欢 提交于 2019-12-07 11:35:01
问题 I have the following query locations = SearchQuerySet().filter_or(content__in=words).models(Location) but it's returning other models as well, I would only want to see Location instances. Using Haystack 2.1.0 and whoosh 2.5 Any ideas? 回答1: My current work around is to use filter(django_ct='app_name.model') 回答2: I ran into the same issue with Model filtering being ignored. I was able to get .models() working by downgrading to Haystack 2.0.0 and Whoosh 2.4.1 回答3: This is based partly on James

Django + Haystack how to do this search

丶灬走出姿态 提交于 2019-12-07 09:14:30
I'm new to Haystack and to the search world so I didn't know how to ask this question. What I want to achieve is the following. Having a search query like: one two I would like to get returned any content like: This one one two two one something one here Is this possible with Haystack + solr/xapian? Is also possible to have a relevance on the result? In the case where both words are hit, that would give more relevance to me. I'm currently using SearchQuerySet in my view but can't achieve that. Cheers So you're basically looking for an OR type query right? By default haystack uses an AND