ElasticSearch和Tire:如何使用html_strip

我想在我的Rails项目中添加char_filter html_strip 。 但我不知道如何以及在哪里使用(重新)轮胎gem。 我甚至不确定我这样做的可能性。

我的代码:

  include Tire::Model::Search include Tire::Model::Callbacks mapping do indexes :author, type: 'string' indexes :content, type: 'string', index_options: "offsets", analyzer: 'snowball', language: "French", char_filter: 'html_strip' indexes :name, type: 'string', index_options: "offsets", analyzer: 'snowball', language: "French", :boost => 5 indexes :topic_id, type: :integer, :index => :not_analyzed end def self.search params query = params[:query] tire.search do query do boolean minimum_number_should_match: 1 do should { string query, fields: [:name], default_operator: "AND", analyzer: 'snowball' } should { string query, fields: [:content], default_operator: "AND", analyzer: 'snowball' } should { string query, fields: [:author], default_operator: "AND" } must { range :topic_id, gt: 0 } end end highlight :content, :author, :name, options: {pre_tags: [''], post_tags: [''], :number_of_fragments => 50} end end 

我真的不确定如何实现它。 我尝试了很多东西,但现在没有结果!

谢谢!

编辑

按照IS04的回答,我改变了我的代码:

 settings analysis: { analyzer: { html_analyzer: { type: 'custom', tokenizer: 'standard', filter: ['classic'], char_filter: ['html_strip'] } } } do mapping do indexes :author, type: 'string' indexes :content, type: 'string', index_options: "offsets", analyzer: 'html_analyzer', search_analyzer: 'snowball', language: "French" indexes :name, type: 'string', index_options: "offsets", search_analyzer: 'snowball', language: "French", boost: 5 indexes :topic_id, type: :integer, index: :not_analyzed end end 

我发布在这里,如果它有一天帮助某人:)

你可以试试像:

 settings analysis: { analyzer: { some_custom_analyzer: { type: 'custom', tokenizer: 'standard', filter: ['classic'], char_filter: ['html_strip'] } } } 

然后:

 indexes :content, type: 'string', index_options: "offsets", analyzer: 'snowball', search_analyzer: 'some_custom_analyzer' 

分析 , 分析器 , 标记 器 , 过滤 器 , 字符filter