python,django,elasticsearch,django-haystack
What version of django-haystack are you using? It looks like there is an open issue for this on the django-haystack GitHub. There is also a patch that should fix it. Looks like you'll have to either wait for the merge, or patch it locally. Issue #1019 Pull Request #1020...
If you use any of the result.object.* fields it will do a DB lookup and hit your SQL database. Try eg. result.city directly, that should use the data from the index and avoid the SQL DB hit.
To address your two concerns: there is no need to repeat the code in the DocumentIndex object, you can access the related Document object via eg. {{ law.object.get_absolute_url }} so put the code in Document yes, summary will be stored three times, once in the DB and twice in the...
Dang it, I was searching for this for a week. Its listed under the SearchField API documentation, which is the superclass of the actual fields in a search index. SearchField.template_name Allows you to override the name of the template to use when preparing data. By default, the data templates for...
python,django,solr,pycharm,django-haystack
The first line of your view replaces the request variable with a context dict containing a CSRF token. Don't do that.
django,django-haystack,geodjango
So I solved this problem by creating a custom field type to handle multiple locations. If anyone else needs multiple locations for a single model instance with django-haystack, like I did, you can download this gist from github to use the MultiLocationField. It works for sure with elasticsearch backend. I'm...
A min_gram of three will only store tokens with three characters or more - "1G" will be ignored. You can either decrease the min_gram to smaller length or switch to another analyser....
I ended up with custom signal processor like so: class RelatedRealtimeSignalProcessor(RealtimeSignalProcessor): """ Extension to haystack's RealtimeSignalProcessor not only causing the search_index to update on saved model, but also for image url, which is needed to show images on search results """ def handle_save(self, sender, instance, **kwargs): if hasattr(instance, 'reindex_related'): for...
python,django,elasticsearch,out-of-memory,django-haystack
Try smaller batch sizes by using --batch-size=XXX Default value is 1000 so try something smaller and work your way up....
python,django,ubuntu,syntax-error,django-haystack
This appears to be a Python version issue. Python 3.2 does not have the u prefix for strings, because strings are unicode by default in Python 3. The prefix was reintroduced in Python 3.3 to make compatibility with 2.7 easier. See the 3.3 release notes. Note that the PyPI page...
python,django,elasticsearch,django-haystack
I have managed to get much better quality results by modifying my filter() query. I learned on the django-haystack documentation about the filter_or() method, which it's possible to concatenate as many times as needed. This way it's easy to match as many fields and/or indexes as needed. For example: sqs...
django,django-haystack,django-cms,whoosh
In my solution to this problem I use aldryn_search to do the integration of Haystack and django-cms. aldryn_search returns a listwith results from all pages, including the ones the current user hast not view-permissions for. To resolve this issue I'm inheriting from AldrynSearchView and override the get_queryset method like this:...
django,apache,solr,django-haystack,solr-multy-valued-fields
Got to the root of the problem. The problem was that solrconfig.xml wasn't configured correctly. By default the schemafactory class is set to ManagedIndexSchemaFactory which overrides the use of schema.xml. By changing the schemaFactory to class ClassicIndexSchemaFactory it forces the use of schema.xml and makes the schema immutable by API...
python,django,elasticsearch,django-haystack
You need to have the real time signal processor activated in settings: HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' ...
django,autocomplete,elasticsearch,django-haystack
It's hard to tell for sure since I haven't seen your full mapping, but I suspect the problem is that the analyzer (one of them) is being used for both indexing and searching. So when you index a document, lots of ngram terms get created and indexed. If you search...
django,django-templates,django-haystack
The ProductIndex class is the main thing here. Haystack will use this configuration to index your Product model according to the fields you have chosen to be indexed and in what way. You can read more about it here. The template which you have created will be used by this...
elasticsearch,django-haystack,spelling
The problem is that I was using the default analyzer, and the default analyzer was using snowball, which was using the snowball index_analyzer, so the words were getting indexes as their stems. Because we still want to search on stemmed words, I added an extra field to my document call...
json,django,django-haystack,paginator
Just use django serialization https://docs.djangoproject.com/en/dev/topics/serialization/ from django.core import serializers ... return HttpResponse(serializers.serialize("json", [q.object for q in results.page(1).object_list]), content_type='application/json') ...
OK, I was confused by your use of "index template" - as I understand it, you're taking about the template used to construct the search document indexed by Haystack. As you note, there is no request involved when that is rendered, so you can't use a RequestContext. That should really...
solr,django-haystack,django-cms
Found the solution. Turns out the information I was looking for is in the Title model, NOT the page model. The Title model allows you to access all the page title, meta tags, menu titles, etc. So I just created a search index based off of that model and it...
An answer is here: https://github.com/toastdriven/django-haystack/pull/720 Request is ready, but still not merged: it lacks docs and tests....
django,elasticsearch,django-haystack
One easy solution could be to have "independant ifs", instead of: # This if/else block is perhaps not a very good solution... if "things" in content and "stuff" in content: sqs = sqs.models(Things, Stuff) elif "things" in content: sqs = sqs.models(Things) elif "stuff" in content: sqs = sqs.models(Stuff) You could...
django,unit-testing,elasticsearch,django-haystack
Figured it out... Haystack's connections singleton needed to be cleared between tests, so: import haystack for key, opts in haystack.connections.connections_info.items(): haystack.connections.reload(key) call_command('clear_index', interactive=False, verbosity=0) ...
After a bit more thought, I found a way around this. In the code above, the problem was occurring in the view = search_view_factory... line, so I needed to create my own SearchView class and override the get_results(self) method in order to apply the filtering after the search has been...
Simple 'in' filter did the job... I feel dumb that this stumped me for so long. sqs = sqs.filter(specialties__in=self.cleaned_data['specialties'])...
django,python-3.x,elasticsearch,django-haystack
You receiving this error message because in Django >= 1.6 Options.module_name changed to .model_name (this is widley abused non-public API) so you just need change in haystack code module_name
django,python-2.7,django-haystack,whoosh
You just need to define a get_absolute_url method explicitly on your model class: class Products(models.Model): ... def get_absolute_url(self): return "/products/%s/" % self.slug It would be even better to use reverse within this method, which will depend on your urlconf. More details here....
python,django,elasticsearch,django-haystack
DIRS in your TEMPLATES dictionary takes precedence over TEMPLATE_DIRS, which is deprecated as of Django 1.8. Set DIRS to [os.path.join(BASE_DIR, 'templates')]. Better yet, you should put this template in an app's template directory (use the app where the model is defined), because that's probably where it should live....
django,database,search,elasticsearch,django-haystack
Buddy,It seems that you are working on a search intensive application.Now my opinion in this regard is as follows-: 1)If u use search intensive queries directly with the database,Then automatically overhead is gonna be very high as each time a separate criteria based query is to be fired to the...
python,django,elasticsearch,django-haystack
Use EdgeNgramField for example in your search index file: class AppIndex(indexes.SearchIndex, indexes.Indexable): ngram_text = indexes.EdgeNgramField() def prepare(self, obj): """Add the content of text field from final prepared data into ngram_text field """ prepared_data = super(AppIndex, self).prepare(obj) prepared_data['ngram_text'] = prepared_data['text'] return prepared_data Then query on that field (Make sure to first...
django-rest-framework,django-haystack
So I added this to my PostSearch view and it solved my issue: ret = serializer.data new_result_list = [] results = ret.get('results') for orderedDict in results: post = orderedDict.get('object') new_result_list.append(post) ret['results'] = new_result_list Basically I made a new list without 'object' wrapper and put it back to return value. ...
django,elasticsearch,django-haystack,pyelasticsearch
Got it working, seemed to be a SELinux error, fixed with: # setenforce 0 For reference, we have these packages installed in a virtualenv: -e git://github.com/toastdriven/[email protected]#egg=django_haystack-master elasticsearch==1.0.0 And elasticsearch-1.1.1-1.noarch through yum on CentOS 6 Edit: The more general fix that doesn't broadly disable SELinux: # setsebool -P httpd_can_network_connect on ...
django,python-2.7,solr,lucene,django-haystack
I found the answer to this problem. In the file pysolr.py, uncomment the following lines: #print 'path: ',path #print 'body:',body The generated solr query will be displayed in the console....
django,elasticsearch,django-haystack
There is a problem with the filter() method on Charfield indexes for django-haystack 2.1.0. You can change them to NgramField instead, for example text = indexes.NgramField(document=True, template_name=True). The problem is that when you use this combination you get just the first character. So it returns you all the matches that...
python,django,elasticsearch,django-haystack
Use MultiValueField which will store all colors associated with product: product_colors = indexes.MultiValueField() Prepare it: def prepare_product_colors(self, obj): return [o.product_color for o in obj.color_set.all()] And use that field directly to filter by product color. Or If you don't want to use search on specific field rather do an auto query...
python,django,django-haystack,xapian
This was an error of Xapian-Haystack that was meanwhile solved.
python,django,elasticsearch,full-text-search,django-haystack
the problem was not enough memory. upgrading from 2GB to 4GB in my VM fixed my problem
django,elasticsearch,full-text-search,django-haystack
Answering it to mark it resolved. It was database config issue. I am having different settings file for different environment, and was having mismatch for database config in both files....
finally found the answer here: ElasticSearch: EdgeNgrams and Numbers Add the following classes and change the Engine under Haystack_connections in settings file to use CustomElasticsearchSearchEngine below instead of default haystack one: class CustomElasticsearchBackend(ElasticsearchSearchBackend): """ The default ElasticsearchSearchBackend settings don't tokenize strings of digits the same way as words, so they...
django,django-models,django-haystack
Since you are using a ForeignKey from the Language to the User without a related_name, you need to access language_set on the user object: {{ object.user.get_full_name }} {% for language in object.user.languages %} {{ language }} {% endfor %} This gives you a list of all languages for a user....
I believe template_name should be template in your views.py. Take a look at the default class SearchView on the haystack Github page....
I did not read the documentation well enough as a result I messed up on the QuerySet part. foo.update_object(some) The above does add the object to the index. Its just that I was not searching for it properly. I was searching for the object after removing it in the following...
python,django,solr,django-haystack,datefield
You should be able to use date_facet(). If you set it's gap_by parameter to year, it will facet by year.
Wow, I can't believe I missed this. if self.cleaned_data['order'] == 'date': if self.cleaned_data['desc'] == 'y': sqs.order_by('-created') else: sqs.order_by('created') needs to be if self.cleaned_data['order'] == 'date': if self.cleaned_data['desc'] == 'y': sqs = sqs.order_by('-created') else: sqs = sqs.order_by('created') ...
I will describe what I did when faced a similar problem. In your index definition, specify a field for the current language. Django-hvad always returns a 'language_code' field if you do a query, so for example: class PostIndex(indexes.SearchIndex, indexes.Indexable): # your field definitions here lan = indexes.CharField(model_attr='language_code') # rest of...
python,django,elasticsearch,django-haystack
Finally solved adding the project2 url to project1 HAYSTACK_CONNECTIONS Let's supose as in the question that project2 url = 123.123.123.123, I've configured my project1 settings.py as: HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'project1.search_backends.CustomElasticSearchEngine', 'URL': '123.123.123.123:9200', 'INDEX_NAME': 'haystack', }, } With this all the querys made from project1 are sent to...
django,elasticsearch,django-haystack
You cannot create one SearchIndex for multiple models; you are not meant to. If your models are similar you could use some inheritance though (but I reckon that Skill & City don't have much in common). You are meant to create SkillIndex & CityIndex. You can search them together; I...
templates,search,django-haystack
Here is how I would do it: First, create a search form that inherits haystack's SearchForm: class ItemSearchForm(SearchForm): def search(self, request): items = super(ItemSearchForm, self).search().models(Item) // Item is your model name shops = super(ItemSearchForm, self).search().models(Shop) return {'items': items, 'shops': shops} Second, create views that uses this form: def searchItems(request): form...