djangosolrdjango-haystackxapian

Django + Haystack how to do this search


I'm new to Haystack and to the search world so I didn't know how to ask this question.

What I want to achieve is the following.

Having a search query like: one two

I would like to get returned any content like:

Is this possible with Haystack + solr/xapian? Is also possible to have a relevance on the result? In the case where both words are hit, that would give more relevance to me.

I'm currently using SearchQuerySet in my view but can't achieve that.

Cheers


Solution

  • So you're basically looking for an OR type query right? By default haystack uses an AND operation for joining queries.

    You can do this two ways:

    Apart from that, you could always join Django Q objects together but considering you have these options, those are probably your best bet.

    For relevance, you should read the Best Practices page which goes into using search templates and making them be your way to show relevant content.

    Hope that helps!