I'm highlighting unnecessary word for example I'm search for "Document CASE No. 2015-331" here the list that searchkick will highlight
here's what's my search looks like
search = ::Document.search params[:q], fields: [:content], where: {id:
params[:id]}, highlight: { tag: 'span class=match-matcher',
fragment_size: @document.content.length}
search.with_highlights.each do |document, highlights|
document.content = highlights[:content]
end
the goal here to highlight the "Document CASE No. 2015-331" only
Looks like your field has been analyzed when indexed. If you want to achieve the exact match and tokens should be searchable the mapping should be "not_analyzed" and the data needs to be re-indexed.
Here you are looking for exact match.
Modify the mapping for you field by adding something like below.
"mappings": {
"properties": {
"city": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}