MC X
MC X

Reputation: 357

exact matching does not work for SQ() in Haystack?

I am trying to use __exact in my Haystack and SOLR4 backend app, but it does not work for SQ() as expected. I am wondering whether __exact just works for SearchQuerySet class. This is my code:

    sqs = super(FacetedSearchForm, self).search() 
    author_sq = SQ()     
    title_sq = SQ() 
    author_sq.add(SQ(author__exact=sqs.query.clean(author)), SQ.OR)       
    title_sq.add(SQ(title__exact=sqs.query.clean(title)), SQ.OR) 
    sqs = sqs.filter(author_sq) 
    sqs = sqs.filter(title_sq)

Does anyone have any idea on how to get __exact work for SearchQuery class?

Upvotes: 0

Views: 258

Answers (1)

user2111922
user2111922

Reputation: 1129

I'm using it like this:

sqs = sqs.filter(SQ(text__exact=criteria) | SQ(entries__exact=criteria) | SQ(attr_content__exact=criteria))

sqs is a SearchQuerySet

Upvotes: 0

Related Questions