I'm pretty new to this so bear with me. Everything seems to work except I can't figure out how to prevent the :p_s
, :gender
, and :part_of_speech
fields from showing in the search results.
This article says I need to indicate no
somewhere so the fields aren't searchable. How do I implement this in the code below? Please let me know if you need more info.
And to be clear, removing those three fields from the indexes
portion below doesn't work. I just added them for sake of illustration.
require 'elasticsearch/model'
class Term < ActiveRecord::Base
...
mappings dynamic: 'false' do
indexes :id, index: :not_analyzed
indexes :name, Index: spanish_analyzer
indexes :p_s
indexes :gender
indexes :part_of_speech
indexes :definition, analyzer: :combined_analyzer
indexes :etymology1, analyzer: :combined_analyzer
indexes :etymology2, analyzer: :combined_analyzer
indexes :uses, analyzer: :combined_analyzer
indexes :notes1, analyzer: :combined_analyzer
indexes :notes2, analyzer: :combined_analyzer
end
end
def self.search(query)
__elasticsearch__.search(
{
query: {
multi_match: {
query: query,
fields: ['name^7', 'definition^6', 'etymology1^5', 'etymology2^4', 'uses^3', 'notes1^2', 'notes2^1'],
operator: 'and'
}
}
}
)
end
end