Precise Django Haystack Filtering

I have a hay search that has the following SearchIndex:

class GrantIndex (indexes.SearchIndex):
    "" "
    This provides the search index for the Grant application.
    "" "
    text = indexes.CharField (document = True, use_template = True)
    year = indexes.IntegerField (model_attr = 'year__year')
    date = indexes.DateField (model_attr = 'date')
    program = indexes.CharField (model_attr = 'program__area')
    grantee = indexes.CharField (model_attr = 'grantee')
    amount = indexes.IntegerField (model_attr = 'amount')
site.register (Grant, GrantIndex)

If I want to search for filtering of any programs that are NOT "Health", I run the following query:

from haystack.query import SearchQuerySet

sqs = SearchQuerySet ()
sqs = sqs.filter (program = 'Health')

Unfortunately, this also creates objects from the "Health \ Other" and "Health \ Cardiovascular" programs. How to stop the search to enable these other programs?

I am running Ubuntu 9.10 with Xapian as the search source code.

+5
source share
5 answers

You probably solved the problem already, but I just stumbled upon the same problem with the Whoosh backend. Maybe those who support Xapian and Wash behave the same? It seems that Whoosh by default closes all CharFields and looks for some kind of content request inside them. Switching to a custom backend, without being able to activate on CharFields, fixed this problem for me.

, - .

+3

, .

sqs = sqs.filter(program__exact='Health')
+1

"prepare_data" \blabla.

0

solr backend _exact ( ).

0

: Xapian-Haystack.

, , Xapian-Haystack , , /.

, "Health\Other" "health" "other". Xapian-Haystack, ., , .

0

All Articles