django-haystack

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

爷,独闯天下 提交于 2019-12-05 14:10:14
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 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 thanks to query caching) or to run the query and post-process the results, regrouping them as you go. from

Django Haystack faceting on the model type

爷,独闯天下 提交于 2019-12-05 10:59:31
I want to facet the results based on the different model_names (classes) returned. Is there an easy way to do this? 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') facet_model_name = CharField(faceted=True) def get_model(self): return Memo def prepare_facet_model_name(self

Haystack search on a many to many field is not working

独自空忆成欢 提交于 2019-12-05 06:56:33
I'm trying to run a search on a model that has a many to many field, and I want to filter the search using this field. here is my current code: search_indexes.py class ListingInex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) business_name = indexes.CharField(model_attr='business_name') category = indexes.MultiValueField(indexed=True, stored=True) city = indexes.CharField(model_attr='city') neighborhood= indexes.CharField(model_attr='neighborhood') state = indexes.CharField(model_attr='state') address = indexes.CharField(model_attr='address

How can I do a fuzzy search using django-haystack and the elasticsearch backend?

泄露秘密 提交于 2019-12-05 04:03:40
It looks as if elasticsearch supports fuzzy queries ( http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query/ ) but I can't figure out a way to have django-haystack pass in that option. I dug into the django-haystack search and it looks as if it's using the 'match_all' query when using the elasticsearch backend. Is it possible to get the fuzzy match behavior without having to modify the django-haystack source code? Haystack Source: https://github.com/toastdriven/django-haystack/blob/master/haystack/backends/elasticsearch_backend.py (the build_search_kwargs method is what I suspect

Haystack queryset contains None elements

╄→尐↘猪︶ㄣ 提交于 2019-12-05 03:31:46
I'm using Haystack for search, and the resulting SearchQuerySet returned contains None elements: >> SearchQuerySet().models(Question, Document, Idea) >> [<SearchResult: idea.idea (pk=3875)>, None, None, None] Running rebuild_index doesn't help. If I remove the .models() call from the first line, the problem goes away. I could just filter out None elements from the results, but I wanted to know if this is intended behaviour? I am using Django 1.4, Whoosh, and Haystack 2.0.0-beta I had this problem when haystack index had records without corresponding records in DB. No, it is definitly not the

Django-haystack full text search working but facets don't

醉酒当歌 提交于 2019-12-05 02:28:33
问题 Using django-haystack and elasticsearch. Full text search is working ok, but I have trouble to implement facets. I've searched tutorial on web but with no success, in other words didn't understand any of them. I am beginner in programing, so some help it will be appreciated. Thank you in advance. Sorry on my english if isn't good, it isn't my primary language. Here is my working full text search. articles.models.py class Article(models.Model): category = models.CharField(max_length=60)

Search over multiple fields

泄露秘密 提交于 2019-12-05 02:16:53
问题 I think I don't unterstand django-haystack properly: I have a data model containing several fields, and I would to have two of them searched: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, default=None) twitter_account = models.CharField(max_length=50, blank=False) My search index settings: class UserProfileIndex(SearchIndex): text = CharField(document=True, model_attr='user') twitter_account = CharField(model_attr='twitter_account') def get_queryset(self): ""

remote autocomplete by typeahead works only on unique queries

假装没事ソ 提交于 2019-12-04 20:43:45
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 250ms on localhost). Firstly, I thought symbols work correctly and names are ignored. But I do get

Main field name (document=True)

心不动则不痛 提交于 2019-12-04 19:56:25
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 from haystack import indexes from myapp.models import Note class NoteIndex(indexes.SearchIndex,

Haystack Not Returning Results that Solr Admin Console Highlights

隐身守侯 提交于 2019-12-04 18:23:33
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 class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType> I have a bunch of one or two word