I am trying to use Elasticsearch-Gem in my project. As far as I understand: by now there is no longer need for Tire-Gem, or am I mistaken?
In my project, I have a search (obivously) that currently applies to a single model. Now I try to avoid wildcards, as they do not scale well, but I cannot get ngram parsers to work correctly. If I search for whole words, the search still works, but not for parts of it.
class Pictures < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
settings :analysis => {
:analyzer => {
:my_index_analyzer => {
:tokenizer => "keyword",
:filter => ["lowercase", "substring"]
},
:my_search_analyzer => {
:tokenizer => "keyword",
:filter => ["lowercase", "substring"]
}
},
:filter => {
:substring => {
:type => "nGram",
:min_gram => 2,
:max_gram => 50
}
}
} do
mapping do
indexes :title,
:properties => {
:type => "string",
:index_analyzer => 'my_index_analyzer',
:search_analyzer => "my_search_analyzer"
}
Maybe someone can give me a hint in the right direction.
source
share