繁体   English   中英

仅在使用ElasticSearch和Tire的情况下,如何按属性过滤搜索?

[英]How to filter search by attribute only if it exists using ElasticSearch and Tire?

现在我写了

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

很好的返回没有app_id或与您的条款相匹配的商品听起来像是针对或过滤器的工作-我会尽力

filter :or, [
    {:not => {:exists => {:field => :app_id}}},
    {:terms => {:app_id => app_ids}}
  ]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM