我使用了 gem elasticsearch-rails 和 elasticsearch-model,我很难在 elasticsearch-rails 中编写这个查询。
SELECT "news".* FROM "news"
WHERE "news"."is_active" = 'true' AND
((priority is not null AND created_at > '2014-07-08 08:55:52.888587') OR
(created_at > '2014-07-08 08:55:52.888820' AND is_persisted = 't') )
ORDER BY "news"."priority" ASC, "news"."created_at" DESC
LIMIT 10 OFFSET 0
在我之前的项目中,我使用了“轮胎模型”,我使用了这样的东西:
filter :bool, must: {and: [{term: {field with options}}, {term: {field with options}}]}
,它适用于轮胎模型
但是如果我在 elasticsearch-rails 中使用这样的东西,它会抛出丢失的过滤错误我写这样的东西来过滤活动记录:
def self.news_index(page = 1)
query =:
response=self.elasticsearch.search query: { match: { is_active: true }}
response=response.page(page)
end
在上述方法中,我想添加带有 bool 选项的组合过滤器。谁能指导我?