django-haystack

Django Haystack and Taggit

为君一笑 提交于 2019-12-03 16:31:29
Is there anybody using Django taggit with haystack? How can we make tags field indexable by haystack? I have tried: class EventIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField( model_attr='descr_en', document=True, use_template=True) text_tr = indexes.CharField(model_attr='descr_tr') tags = indexes.MultiValueField() def prepare_text(self, obj): return '%s %s' % (obj.title_en, obj.descr_en) def prepare_text_tr(self, obj): return '%s %s' % (obj.title_tr, obj.descr_tr) def prepare_tags(self, obj): return [tag.name for tag in obj.tags.all()] def get_model(self): return Event

Haystack - Why does RealtimeSearchIndex sometimes not update my saved object

谁都会走 提交于 2019-12-03 11:38:15
I'm using Haystack and Whoosh with Django Within search_index.py I have this class PageIndex(RealTimeSearchIndex): text = CharField(document=True, use_template=True) creator = CharField(model_attr='creator') created = DateTimeField(model_attr='created') org = CharField(model_attr='organisation') site.register(Page, PageIndex) My template looks like this {{ object.name }} {{ object.description }} {{ object.template|striptags }} {% for k,v in object.get_variables.items %} {{ v }} {% endfor %} If I save the Page with an updated name or description then it updates straight away and includes the

Django-Haystack using Amazon Elasticsearch hosting with IAM credentials

…衆ロ難τιáo~ 提交于 2019-12-03 08:12:55
I am hoping to use Amazon's Elasticsearch server to power a search of longtext fields in a Django database. However, I also don't want to expose this search to those who don't have a log in and don't want to rely on security through obscurity or some IP restriction tactic (unless it would work well with an existing heroku app, where the Django app is deployed). Haystack seems to go a long way toward this, but there doesn't seem to be an easy way to configure it to use Amazon's IAM credentials to access the Elasticsearch service. This functionality does exist in elasticsearch-py, whichi it uses

Whoosh index viewer

為{幸葍}努か 提交于 2019-12-03 08:09:10
问题 I'm using haystack with whoosh as backend for a Django app. Is there any way to view the content (in a easy to read format) of the indexes generated by whoosh? I'd like to see what data was indexed and how so I can better understand how it works. 回答1: You can do this pretty easily from python's interactive console: >>> from whoosh.index import open_dir >>> ix = open_dir('whoosh_index') >>> ix.schema <<< <Schema: ['author', 'author_exact', 'content', 'django_ct', 'django_id', 'id', 'lexer',

Count total search objects count in template using django-haystack

廉价感情. 提交于 2019-12-03 06:54:18
I am using django haystack with xapian as the backend search engine. I am using FacetedSearchView and FacetedSearchForm for faceting over the search. I have passed searchqueryset to the FacetSearchView in my urls.py file. But the problem is I cannot access that searchqueryset in template. All I want to do is count the number of objects in searchqueryset found. In shell I could achieve it using S earchQuerySet().filter(content="foo").count() , how can I do that similarly in the template? Please guide. I want the total number of objects matching the search. Francis Yaconiello Haystack uses the

Django Haystack - Show results without needing a search query?

删除回忆录丶 提交于 2019-12-03 06:17:12
I would like to display all results which match selected facets even though a search query has not been inserted. Similar to how some shop applications work e.g. Amazon e.g. Show all products which are "blue" and between $10-$100. Haystack does not return any values if a search query is not specified. Any ideas how I can get around it? Thanks! If anyone is still looking, there's a simple solution suggested in haystack code: https://github.com/toastdriven/django-haystack/blob/master/haystack/forms.py#L34 class SearchForm(forms.Form): def no_query_found(self): """ Determines the behavior when no

Updating a Haystack search index with Django + Celery

怎甘沉沦 提交于 2019-12-03 02:41:07
问题 In my Django project I am using Celery. I switched over a command from crontab to be a periodic task and it works well but it is just calling a method on a model. Is it possible to update my Haystack index from a periodic task as well? Has anyone done this? /manage.py update_index That's the command to update the index from the Haystack documentation but I'm not sure how to call that from a task. 回答1: the easiest way to do this would probably be to run the management command directly from

Whoosh index viewer

半世苍凉 提交于 2019-12-02 20:51:22
I'm using haystack with whoosh as backend for a Django app. Is there any way to view the content (in a easy to read format) of the indexes generated by whoosh? I'd like to see what data was indexed and how so I can better understand how it works. zeekay You can do this pretty easily from python's interactive console: >>> from whoosh.index import open_dir >>> ix = open_dir('whoosh_index') >>> ix.schema <<< <Schema: ['author', 'author_exact', 'content', 'django_ct', 'django_id', 'id', 'lexer', 'lexer_exact', 'published', 'published_exact']> You can perform search queries directly on your index

Updating a Haystack search index with Django + Celery

我的梦境 提交于 2019-12-02 16:16:22
In my Django project I am using Celery. I switched over a command from crontab to be a periodic task and it works well but it is just calling a method on a model. Is it possible to update my Haystack index from a periodic task as well? Has anyone done this? /manage.py update_index That's the command to update the index from the Haystack documentation but I'm not sure how to call that from a task. the easiest way to do this would probably be to run the management command directly from python and run it in your task from haystack.management.commands import update_index update_index.Command()

Django - Strange behavior using static files

二次信任 提交于 2019-12-02 11:59:51
I'm new to Django. I'm getting insane trying to understand what is going on with static files(css's and images). The resume of the problem is the following... when I use static views from a 3rd party App(Haystack) I can't use static files. My project have this directory structure: 1001empbr (name of the folder for the project) | |------ 1001emp (name of the django project) | |------ 1001empbr (name of my App) |------ site_media (folder with static files CSS/JPG/GIF) |------ templates (folder with the templates) When I use urlpatterns(urls.py) like this works great: import os.path # Para poder