django-haystack

Haystack indexing related model issue

无人久伴 提交于 2020-01-07 00:05:22
问题 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

django haysteck FacetedSearchView returning empty results?

喜你入骨 提交于 2020-01-06 05:36:06
问题 I'm using Django haystack FacetedSearchView my views.py : from haystack.generic_views import FacetedSearchView as BaseFacetedSearchView class FacetedSearchView(BaseFacetedSearchView): template_name = 'test.html' facet_fields = ['source'] and in urls.py : url(r'^search', FacetedSearchView.as_view(), name='haystack_search') and in test.html I'm printing the facets. when I issue request as follow: 127.0.0.1:8000:/search the content of the factes context object is empty dict. but I think it

Index related table using Haystack/Whoosh

吃可爱长大的小学妹 提交于 2020-01-06 03:06:45
问题 How can I index a related table: class Foo(models.Model): name = models.CharField(max_length=50) Class FooImg(models.Model): image = models.ImageField(upload_to='img/', default = 'img/no-img.jpg', verbose_name='Image', ) foo = models.ForeignKey(Foo, default=None, null=True, blank=True) I want to index FooImg, so that I can get the images associated with Foo. I have already indexed Foo, and it works perfectly fine, it returns expected result. So in my template I have: {% for r in foo_search %}

Unescape search results with django haystack and elasticsearch

[亡魂溺海] 提交于 2020-01-06 02:15:32
问题 I'm using django-haystack with elasticsearch backend. The data contains names of books that may contain special characters like & , ' or "" . The indexed data escapes these characters and the search results shows the escaped data. How do I tell haystack or elasticsearch to turn off escaping OR unescape the characters when I want to use the results in a non-HTML context i.e. as plain text ? Here's my code: #search_indexes.py class Book(indexes.SearchIndex, indexes.Indexable): text = indexes

Using django haystack search with global search bar in template

柔情痞子 提交于 2020-01-05 08:12:35
问题 I have a django project that needs to search 2 different models and one of the models has 3 types that I need to filter based on. I have haystack installed and working in a basic sense (using the default url conf and SearchView for my model and the template from the getting started documentation is returning results fine). The problem is that I'm only able to get results by using the search form in the basic search.html template and I'm trying to make a global search bar work with haystack

django-haystack + Whoosh SearchQuerySet().all() always None

删除回忆录丶 提交于 2020-01-05 05:55:19
问题 I am using: django: 1.9.7 django-haystack: 2.5.0 whoosh: 2.7.4 search_index.py class ProfileIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) last_name= indexes.CharField(model_attr='last_name') content_auto = indexes.EdgeNgramField(model_attr='first_name') def get_model(self): return User def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.all() user_text.txt {{

haystack isn't indexing my multivalue

╄→гoц情女王★ 提交于 2020-01-04 05:34:48
问题 I'm trying to get a MultiValueField to be indexed, but it's just not working. Here is what I have: class Public_PollIndex(SearchIndex): text = CharField(model_attr='question', document=True, use_template=True) date_created = DateTimeField(model_attr='date_created') choices = MultiValueField() def get_model(self): return Public_Poll def prepare_choices(self, obj): # For some silly reason we get (u"choice",) instead of just u"choice" # So we unpack... c = [ str(c) for (c,) in obj.choice_set

haystack.exceptions.MissingDependency: The 'elasticsearch' backend requires the installation of 'elasticsearch'

自古美人都是妖i 提交于 2020-01-03 05:27:10
问题 I am newbie to Django-haystack. I got an error while following Django-Haystack documentation. Command execution order, I followed: I started elasticsearch server (1.7.3) using command prompt and I am able to access http://127.0.0.1:9200/ python manage.py rebuild_index Output: WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'. Your choices after this are to restore from backups or rebuild via the rebuild_index command. Are you sure you wish to

Haystack search on a many to many field is not working

巧了我就是萌 提交于 2020-01-02 03:29: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=

How do I do a partial field match using Haystack?

旧街凉风 提交于 2019-12-28 16:42:18
问题 I needed a simple search tool for my django-powered web site, so I went with Haystack and Solr. I have set everything up correctly and can find the correct search results when I type in the exact phrase, but I can't get any results when typing in a partial phrase. For example: "John" returns "John Doe" but "Joh" doesn't return anything. Model: class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) Search Index: class PersonIndex