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 entries in my database which I would like to match against the user’s query. So for example, I might have one object with title "dog" and another with title "cat". If the user searches for "dog cat" then I would like to return both the dog and cat objects for that query.
Similarly, if I search for "my cool website" I would like the field with "website" to be returned.
I tried using the solr admin interface to check to make sure my queries were getting matched. Everything seems okay there:
:
The issue is when I use the haystack default search interface to search for that same query:

As you can see, no results are found. I tried using KeywordFactory and a bunch of different solr configurations. If I’m not mistaken then the query should be getting matched. I’m not sure why haystack is coming up empty though.
Thanks for any help / suggestions on if this is the best way to go about such a search.
Few month ago I worked with
django-haystackand solr. I also had a problems with making some special queries to solr.Actually it should be solved by addng next line to
settings.py:But it does not work for me.
So, in my case it was solved by subclassing
SearchViewclass. This is small snippet from my project:And urls.py
And that’s it.