您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

轮胎术语过滤器不起作用

轮胎术语过滤器不起作用

您的问题很可能是由于对该status字段使用认映射而引起的,该映射会将其标记化-小写,拆分为单词等。

比较这两个:

http://localhost:9200/myindex/_analyze?text=Text1&analyzer=standard

http://localhost:9200/myindex/_analyze?text=Text1&analyzer=keyword

您的解决方案是在映射中使用keyword分析器(或将字段设置为not_analyzed)。如果该字段不是“枚举”类型的数据,则可以使用多字段功能

有效的Ruby版本如下所示:

require 'tire'

Tire.index('myindex') do
  delete
  create mappings: {
    document: {
      properties: {
        status: { type: 'string', analyzer: 'keyword' }
      }
    }
  }

  store status: 'Test1'
  store status: 'Test2'

  refresh
end

search = Tire.search 'myindex' do
  query do
    filtered do
      query { all }
      filter :terms, status: ['Test1']
    end
  end
end

puts search.results.to_a.inspect

注意:在没有提供索引映射,示例数据等的情况下,极不可能(在这种情况下为例外)提供合理的建议。

其他 2022/1/1 18:14:22 有422人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶