django-haystack

Can't build index for solr/haystack: unknown field 'django_id'

浪尽此生 提交于 2019-11-29 23:05:56
问题 I'm trying to follow along the haystack tutorial. I run into an error when I run manage.py rebuild index I get the following error: WARNING: This will irreparably remove EVERYTHING from your search index. Your choices after this are to restore from backups or rebuild via the `rebuild_index` command. Are you sure you wish to continue? [y/N] y Removing all documents from your index because you said so. All documents removed. /Users/heri0n/python_env/lib/python2.7/site-packages/django/db/models

haystack - how you display data from multiple models with ForeignKeys?

淺唱寂寞╮ 提交于 2019-11-29 14:33:22
问题 I have two models: models.py class model1 (models.Model): field1_model1 = models.CharField() filed2_model1 = models.CharField() class model2 (models.Model): field1_model2 = models.ForeignKey(model1) field2_model2 = models.CharField() Using Haystack I want to do a text search based on the filed1_model1 but when I do that I want to show also filed2_model2 in the search results. What goes in the search_indexes.py and also in the search.html template files to make this happen? 回答1: First you

Django Haystack - Filter by substring of a field using SearchQuerySet ()

a 夏天 提交于 2019-11-29 07:26:09
I have a Django project that uses SOLR for indexing. I'm trying to do a substring search using Haystack's SearchQuerySet class. For example, when a user searches for the term "ear" , it should return the entry that has a field with the value: "Search" . As you can see, "ear" is a SUBSTRING of "Search" . (obviously :)) In other words, in a perfect Django world I would like something like: SearchQuerySet().all().filter(some_field__contains_substring='ear') In the haystack documentation for SearchQuerySet ( https://django-haystack.readthedocs.org/en/latest/searchqueryset_api.html#field-lookups ),

How to add something to PYTHONPATH?

坚强是说给别人听的谎言 提交于 2019-11-29 01:24:10
I downloaded a package (called pysolr 2.0.15) to my computer to be used with Haystack. The instructions asks me to add pysolr to my PYTHONPATH. What exactly does that mean? After extracting the pysolr files, I ran the command python setup.py install and that's about it. What did that do and do I need to do anything else? Thanks for the help! The pythonpath tells python were to look for modules, for example you might have written a library that you want to use in several applications and stored it in the path /mylibs/python/ you would then have to add that path to the pythonpath for python to

Filter Django Haystack results like QuerySet?

六月ゝ 毕业季﹏ 提交于 2019-11-28 21:37:38
Is it possible to combine a Django Haystack search with "built-in" QuerySet filter operations, specifically filtering with Q() instances and lookup types not supported by SearchQuerySet? In either order: haystack-searched -> queryset-filtered or queryset-filtered -> haystack-searched Browsing the Django Haystack documentation didn't give any directions how to do this. You could filter your queryset based on the results of a Haystack search, using the objects' PKs: def view(request): if request.GET.get('q'): from haystack import ModelSearchForm form = ModelSearchForm(request.GET, searchqueryset

Apache solr search part of the word

被刻印的时光 ゝ 提交于 2019-11-28 04:24:00
I'm using apache solr search engine for indexing my website database.. I'm using django+ http://haystacksearch.org/ So let's say I have document that have word "Chicken" When I search for "chicken" - solr can find this document But When I search "chick" - it does not find anything.. Is there a way to fix this ? Brian Note: The following solution is Solr 1.4 (and above) specific! For more flexibility, I would recommend indexing your data with the NGramTokenizerFactory to do complete front and back wildcard searches. If you just want to search for substrings at the beginning or end of the string

Django Haystack - Filter by substring of a field using SearchQuerySet ()

余生长醉 提交于 2019-11-28 01:06:46
问题 I have a Django project that uses SOLR for indexing. I'm trying to do a substring search using Haystack's SearchQuerySet class. For example, when a user searches for the term "ear" , it should return the entry that has a field with the value: "Search" . As you can see, "ear" is a SUBSTRING of "Search" . (obviously :)) In other words, in a perfect Django world I would like something like: SearchQuerySet().all().filter(some_field__contains_substring='ear') In the haystack documentation for

How to add something to PYTHONPATH?

倖福魔咒の 提交于 2019-11-27 15:49:51
问题 I downloaded a package (called pysolr 2.0.15) to my computer to be used with Haystack. The instructions asks me to add pysolr to my PYTHONPATH. What exactly does that mean? After extracting the pysolr files, I ran the command python setup.py install and that's about it. What did that do and do I need to do anything else? Thanks for the help! 回答1: The pythonpath tells python were to look for modules, for example you might have written a library that you want to use in several applications and

Filter Django Haystack results like QuerySet?

喜欢而已 提交于 2019-11-27 14:01:53
问题 Is it possible to combine a Django Haystack search with "built-in" QuerySet filter operations, specifically filtering with Q() instances and lookup types not supported by SearchQuerySet? In either order: haystack-searched -> queryset-filtered or queryset-filtered -> haystack-searched Browsing the Django Haystack documentation didn't give any directions how to do this. 回答1: You could filter your queryset based on the results of a Haystack search, using the objects' PKs: def view(request): if

Apache solr search part of the word

时光总嘲笑我的痴心妄想 提交于 2019-11-27 05:20:13
问题 I'm using apache solr search engine for indexing my website database.. I'm using django+http://haystacksearch.org/ So let's say I have document that have word "Chicken" When I search for "chicken" - solr can find this document But When I search "chick" - it does not find anything.. Is there a way to fix this ? 回答1: Note: The following solution is Solr 1.4 (and above) specific! For more flexibility, I would recommend indexing your data with the NGramTokenizerFactory to do complete front and