pythonelasticsearchdjango-haystackwhooshsearchqueryset

Union of 2 SearchQuerySet in django haystack


Is there any way to get an union of two or more searchqueryset ? For example :-

query1 = SearchQuerySet().filter(authors=query)
query2 = SearchQuerySet().filter(title=query)

How do I combine both the queries together so that i get a union of the 2 queries ?


Solution

  • SearchQuerySet implements the QuerySet interface to some extent, so you can try:

    query1 | query2