簡體   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