Djayo haystack, whoosh search, boost

I have installed django with haystack. Here is my main model:

class Apple(models.Model):
    pname = models.CharField(max_length=127)
    qname = models.CharField(max_length=127)

      

I want to search in apples that have a "test query" in pname or qname. but I want to show objects that have "test query" in their pname field above objects that have it in their qname fields.

and here is my search_indexes:

class AppIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    pname = CharField(model_attr='pname', boost=1.2)
    qname = CharField(model_attr='qname')

      

here is the apple_text.txt file:

{{ object.pname }}
{{ object.qname }}

      

I've searched a lot and I think that with boost = 1.2 it should work, but it doesn't work and there is no difference between objects that have a "test query" in their pname and qname fields.

+3


source to share


1 answer


I'm not sure if it has changed since the question was asked, but I believe you want field_boost = 1.2



0


source







All Articles