【问题标题】:Price range facets are always disabled with zero count价格范围方面始终禁用,计数为零
【发布时间】:2019-09-22 06:12:41
【问题描述】:

我使用 Oscar 2.0 和 ElasticSearch 2.4.6 的默认设置,但是,由 facets 生成的价格范围数据总是被禁用,计数为零,与字段相关的其他数据(评级和产品类别)很好

我注意到 self.results.facet_counts() 的输出只是计算有价格的项目数,而不是使用提供的范围查询,但是,search_query() 下的 quert_facets 信息看起来不错,显示所需的查询范围

self.results.facet_counts() screenshot

Search_QuerySet.quert_facets screenshot

context output

# Search facets
OSCAR_SEARCH_FACETS = {
    'fields': OrderedDict([
        ('product_class', {'name': _('Type'), 'field': 'product_class'}),
        ('rating', {'name': _('Rating'), 'field': 'rating'}),
    ]),
    'queries': OrderedDict([
        ('price_range',
         {
             'name': _('Price range'),
             'field': 'price',
             'queries': [
                 # This is a list of (name, query) tuples where the name will
                 # be displayed on the front-end.
                 (_('0 to 20'), '[0 TO 20]'),
                 (_('20 to 40'), '[20 TO 40]'),
                 (_('40 to 60'), '[40 TO 60]'),
                 (_('60+'), '[60 TO *]'),
             ]
         }),
    ]),
}

【问题讨论】:

标签: django-oscar


【解决方案1】:

零计数表示该价格范围内没有产品被编入索引。尝试将产品价格设置在所示范围内,然后重建索引。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    相关资源
    最近更新 更多