【问题标题】:Query group results not returning all results?查询组结果不返回所有结果?
【发布时间】:2016-06-22 04:06:08
【问题描述】:

从今天开始,我一直在使用查询组来进行我正在运行的一个小测试。

我在查询中定义了 2 个组,1 个在某个日期时间之前过滤,另一个在该日期时间之后。以下是我的组设置的一个非常简化的示例。

group do
  query "before" do
    with(:planned).less_than mydate
  end
  query "after" do
    with(:planned).greater_than mydate
  end
end

执行查询后,我循环遍历我的组并看到以下结果:

results.group(:queries).groups.each do |g|
  group_total = g.total
  group_results_count = g.results.count
end

查询before:
group_total = 2
group_results_count = 1

查询after:
group_total = 3
group_results_count = 1

我的组的结果计数始终为 1。total 值实际上是正确的,我通过 Solr 管理面板仔细检查了这一点。

我是否在这里误解了某些东西,或者小组的工作方式与我的预期不同。

我在 Solr 5.3.1 上运行

【问题讨论】:

    标签: ruby-on-rails solr sunspot


    【解决方案1】:

    默认情况下 Solr returns one result for each group - 请参阅 group.limit 参数。

    According to the source,sunspot 中的分组模块使用了limit参数:

      def to_params
        params = {
          :group            => "true",
          :"group.ngroups"  => "true",
        }
    
        params.merge!(@sort.to_params("group."))
        params[:"group.field"] = @fields.map(&:indexed_name) if @fields.any?
        params[:"group.query"] = @queries.map(&:to_boolean_phrase) if @queries.any?
        params[:"group.limit"] = @limit if @limit
        params[:"group.truncate"] = @truncate if @truncate
    
        params
      end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多