我正在使用 Tire for rails 来集成弹性搜索。这有点令人困惑,我想确保我做对了。
这是我应用多个过滤器的方式吗?我基本上是在尝试检查'mixtape_id IS NULL AND artist_id IS NOT NULL'
def self.search(query)
tire.search() do
query { string query }
filter :exists, { field: 'artist_id' }
filter :not, { exists: { field: 'mixtape_id' } }
end
end
这是我的第二次尝试,似乎仍然没有工作
def self.search(query)
tire.search(load: true) do
query { string query }
filter :and, [
{ exists: { field: 'artist_id' } },
{ not: { exists: { field: 'mixtape_id' } } }
]
end
end
谢谢