I've just updated to Django Haystack 2.5.0 on Django 1.9.6 and am still 
seeing this problem. Whether I defined boost or not on the brand name 
field, or through the prepare method the `score` attribute on the search 
results never change. 

I see the boost coming through on the `prepared_results` dictionary that 
gets sent through the elasticsearch `builk`. And I see the `brand_name` 
field boost in elasticsearch as well:

curl 'localhost:9200/haystack/_mapping/modelresult/field/brand_name/'


{"haystack":{"mappings":{"modelresult":{"brand_name":{"full_name":"brand_name","mapping":{"brand_name":{"type":"string","boost":1.75,"analyzer":"snowball"}}}}}}


So what am I missing? Is this an AWS only issue? Is this an elasticsearch 
issue?


On Tuesday, May 24, 2016 at 1:33:17 PM UTC-4, John Obelenus wrote:
>
> My project in on Django 1.9, and haystack doesnt have a compatible release 
> yet. I was working off master and then I realized that a bunch of boost 
> support for elasticsearch was being removed. So I backported my project to 
> 1.8 so I could use the 2.4.1 official release to see if I can get Document 
> and Field boosting working. It seems to me that  neither are working.
>
> Here is what I am doing:
> from haystack.query import SearchQuerySet, SQ, AutoQuery
> search_term = 'C100'
> sqs = SearchQuerySet().models(Product).filter(SQ(text=AutoQuery(
> search_term)) | SQ(brand_name=search_term) )
> for s in sqs:
>     print s.boost, s.score, s.brand_name, ':', s.object.name
>
> And no matter how I define the indexes the score never changes. Here are 
> three definitions I am trying and you can see the output of the above code 
> in the class comment:
> class ProductIndex(CelerySearchIndex, indexes.Indexable):
>     """
> 1.5 0.84893364 Zacuto : Zacuto Recoil Shoulder Rig for C100, C100II & C300
> 1.5 0.84868896 Zacuto : Zacuto Z-Finder Pro for Canon C100
> 1.0 0.70724076 Zacuto : Zacuto Studio Baseplate with 12" Rods for C100/
> C100II/C300/C500 
> 1.0 0.70021886 Canon : Canon CA-930 Battery Charger for C100/C100II/C300/
> C500
> 1.0 0.6494849 Anton Bauer : Anton Bauer QRC-CA940 Battery Plate for Canon 
> C500, C300 & C100
> 1.0 0.6002867 Canon : Canon BP-970G Battery Pack for C100/C100II/C300/C500
> 2.0 0.5658623 Canon : Canon C100 Mark II Digital Cinema Camera EF Mount
> 1.5 0.4332277 Canon : Canon 100 f/2.8L IS Macro
>     """
>     text = indexes.CharField(document=True, use_template=True)
>     product_id = indexes.IntegerField(model_attr='id', null=False)
>     brand_name = indexes.CharField(model_attr='brand__name', null=True, 
> weight=1.75)
>
>
>     def get_model(self):
>         return models.Product
>
>
>     def index_queryset(self, using=None):
>         return self.get_model().objects.filter(is_active=True)
>
>
>     def prepare(self, instance):
>         data = super(ProductIndex, self).prepare(instance)
>         data['boost'] = 1.5  # even weight everything
>         if instance.is_camera:
>             data['boost'] = 2.0  # weight cameras higher
>         elif instance.is_accessory:
>             data['boost'] = 1.0  # weight accessories lower
>         return data
>
>
>
>
> class ProductIndex(CelerySearchIndex, indexes.Indexable):
>     """
> None 0.84893364 Zacuto : Zacuto Recoil Shoulder Rig for C100, C100II & 
> C300
> None 0.84868896 Zacuto : Zacuto Z-Finder Pro for Canon C100
> None 0.70724076 Zacuto : Zacuto Studio Baseplate with 12" Rods for 
> C100/C100II/C300/C500 
> None 0.70021886 Canon : Canon CA-930 Battery Charger for 
> C100/C100II/C300/C500
> None 0.6494849 Anton Bauer : Anton Bauer QRC-CA940 Battery Plate for Canon 
> C500, C300 & C100
> None 0.6002867 Canon : Canon BP-970G Battery Pack for C100/C100II/C300/C500
> None 0.5658623 Canon : Canon C100 Mark II Digital Cinema Camera EF Mount
> None 0.4332277 Canon : Canon 100 f/2.8L IS Macro
>     """
>     text = indexes.CharField(document=True, use_template=True)
>     product_id = indexes.IntegerField(model_attr='id', null=False)
>     brand_name = indexes.CharField(model_attr='brand__name', null=True, 
> weight=5.0)
>
>
>     def get_model(self):
>         return models.Product
>
>
>     def index_queryset(self, using=None):
>         return self.get_model().objects.filter(is_active=True)
>
>
> class ProductIndex(CelerySearchIndex, indexes.Indexable):
>     """
> None 0.84893364 Zacuto : Zacuto Recoil Shoulder Rig for C100, C100II & C300
> None 0.84868896 Zacuto : Zacuto Z-Finder Pro for Canon C100
> None 0.70724076 Zacuto : Zacuto Studio Baseplate with 12" Rods for C100/
> C100II/C300/C500 
> None 0.70021886 Canon : Canon CA-930 Battery Charger for C100/C100II/C300/
> C500
> None 0.6889441 Anton Bauer : Anton Bauer QRC-CA940 Battery Plate for Canon 
> C500, C300 & C100
> None 0.6002867 Canon : Canon BP-970G Battery Pack for C100/C100II/C300/
> C500
> None 0.5658623 Canon : Canon C100 Mark II Digital Cinema Camera EF Mount
> None 0.4332277 Canon : Canon 100 f/2.8L IS Macro
>     """
>     text = indexes.CharField(document=True, use_template=True)
>     product_id = indexes.IntegerField(model_attr='id', null=False)
>     brand_name = indexes.CharField(model_attr='brand__name', null=True)
>
>
>     def get_model(self):
>         return models.Product
>
>
>     def index_queryset(self, using=None):
>         return self.get_model().objects.filter(is_active=True)
>
>
> The score never changes despite document boost, or field boost against the 
> non-boosted index. The haystack documentation says this stuff is supported, 
> and I'm following the documentation example of how to query against boosted 
> fields. Am I doing something entirely wrong? What else can I try to get 
> this working?
>

-- 
You received this message because you are subscribed to the Google Groups 
"django-haystack" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-haystack+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to