field boosting: how should I query?

94 views
Skip to first unread message

Eamonn Faherty

unread,
May 16, 2013, 11:28:14 AM5/16/13
to django-...@googlegroups.com
I have a single search index with several fields.  I have set boost on them.  I have rebuilt my index and elastic search _mapping shows the correct boost values so I am confident it is setup as expected.

Within my search index I have a field called text which is my document and within the template for it I am adding all of the attributes so they are searchable.

The problem I have is that boost does not seem to work.

I have a unique term that I have added to two different fields of two different models.  The one with the higher boost is not being returned first.

I am guessing the problem is my query: 

SearchQuerySet().filter(content=self.cleaned_data.get('q'))

Is this what it should be?

Ben Lopatin

unread,
May 16, 2013, 10:54:27 PM5/16/13
to django-...@googlegroups.com
It's entirely possible that your boost values will need to be adjusted.

Try changing the boost value to something significantly higher than the current value to see if that changes the score. It's helpful to try searches in the console after changing boost values and indexing to see how the score values have changed.

Eamonn Faherty

unread,
May 17, 2013, 7:33:09 AM5/17/13
to django-...@googlegroups.com
Changing the boost value and rebuilding my index has no effect on the score.

This is so weird.  There are not really any docs on field boosting and there does not seem to be anybody talking about it working.

Ricardo Silva

unread,
Jun 10, 2014, 6:38:36 PM6/10/14
to django-...@googlegroups.com
The filter(content=blah).filter(title=blah) didn't work for me. It's execute an AND operation. But when I created a query using :

from haystack.query import SearchQuerySet, SQ
sq_keyword = SQ()
sq_keyword.add(SQ(title='fox'), SQ.OR)
sq_keyword.add(SQ(content='fox'), SQ.OR)
SearchQuerySet().filter(sq_keyword)

It worked.


On Wednesday, May 22, 2013 10:55:35 AM UTC-3, Greg Humphreys wrote:
You're only searching the content field -- if you want to search other fields, you have to search other fields :

SearchQuerySet().filter(content=blah).filter(title=blah).filter(author=blah)

Yigit Guler

unread,
May 9, 2015, 8:32:46 PM5/9/15
to django-...@googlegroups.com
It worked on my project as well. Thanks!
Reply all
Reply to author
Forward
0 new messages