Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost not working in django-haystack

I am trying to add boost into my haystack search but sadly not able to. This is my search_indexes.py.

class feedIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, use_template=True)
    feed_text = indexes.EdgeNgramField(model_attr='feed_text',null=True)
    tags = indexes.CharField(model_attr='tags')

    def get_model(self):
        return Feed

    def prepare_feed_text(self, obj):
        return "Feed"

    def prepare(self, obj):
        data = super(feedIndex, self).prepare(obj)
        data['boost'] = 1.5
        return data

What else i need to add. Because this i found only this in tutorial. When i run rebult_index i am able to see the boost associated with field in http://localhost:9200/_search . My search backend is elasticsearch. I have gone through all questions related to this but didnt find useful for me.

like image 218
Amarpreet Singh Avatar asked May 31 '26 23:05

Amarpreet Singh


1 Answers

Try using data["_boost"]. I forget how/why this works for us unfortunately.

like image 52
Stephen Paulger Avatar answered Jun 02 '26 20:06

Stephen Paulger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!