1

Say I have a model Person for which there is a PersonIndex class in search_indexes.py that makes all fields of it searchable. How can I make a search within only those entries where say the has_title field is True?

I tried the following, but it just searches among all entries, not just the ones where has_title is True:

srch = request.GET.get('search', "") 
sqs = SearchQuerySet().filter(has_title=True)
clean_query = sqs.query.clean(srch)
results = sqs.raw_search(clean_query)

I am using Whoosh 2.4.1, Django-haystack 1.2.7 and Django 1.4.

Bentley4
  • 10,678
  • 25
  • 83
  • 134

1 Answers1

0

Use filter(content=clean_query) instead of raw_search(clean_query). See here for more details.

Community
  • 1
  • 1
Bentley4
  • 10,678
  • 25
  • 83
  • 134