I have a product index with keywords as multivalued field
class ProductIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
keywords = indexes.MultiValueField(faceted=True)
def prepare_keywords(self, product):
return [p.name for p in product.tags.all()]
I need to find Products having keywords exactly as lightning
. I use this query -
SearchQuerySet().models(Product).filter(keywords__exact=u'Lighting')
But this also gives me the Products having lightning
as a part of the word. Like
print SearchQuerySet().models(Product).filter(keywords__exact=u'Lighting')[1].keywords
[u'LED lighting', u'Optic Lighting']
What is the correct way of doing this?
just look at example/solr/collection1/conf/schema.conf
<field name="keywords" type="text_en" indexed="true" stored="true" multiValued="true" />
i think the exact only worked on string fields not text fields. you must to edit this configuration and create keyword field like this:
<field name="keywords" type="string" indexed="true" stored="true" multiValued="true" />