2

现在我写了

Tire.search INDEX_NAME do
  query do
    filtered do
      query { string term }
      filter :or, { missing: { field: :app_id } },
                  { terms: { app_id: app_ids } }
    end
  end
end.results.to_a
4

1 回答 1

1

好吧,返回没有 app_id 或与您的条款匹配的项目听起来像是一个或过滤器的工作 - 我会尝试

filter :or, [
    {:not => {:exists => {:field => :app_id}}},
    {:terms => {:app_id => app_ids}}
  ]
于 2013-01-10T14:28:16.613 回答