I am trying to create this custom analyzer and for some reason I am getting the Analyzer [] not found for field []
error... I looked around a lot and tried different implementations and I think I have the right syntax for it... Here it is:
settings :number_of_shards => 5,
:number_of_replicas => 2,
:analysis => {
:analyzer => {
:ticker_analyzer => {
"type" => 'custom',
"tokenizer" => 'ticker_pattern',
"filter" => [ 'word_delimiter_filter', 'standard' ]
}
},
:filter => {
:word_delimiter_filter => {
"type" => 'word_delimiter',
"preserve_original" => true
}
},
:tokenizer => {
:ticker_pattern => {
"type" => 'pattern',
"pattern" => '\w+'
}
}
} do
mapping do
# ... some more indexes that work fine, with regular analyzers
indexes :company_ticker, type: 'string', boost: 5.0, analyzer: 'ticker_analyzer', as: 'index_company_ticker'
end
end
So I get the error Analyzer [ticker_analyzer] not found for field [company_ticker]
.
Any ideas why?
Also, I've seen some examples where I won't need to pass a block to the settings
option. I would just close settings
and define mapping
afterwards and it would work? (I've seen this at other people posting code snippets...)
Thank you!
-Vlad
Ok, so this is the actual problem that I was having and why this was not working.
It is because I was trying to create an index that would use the mapping from this model (I was not trying to do Model.create_elasticsearch_index) but with something like
index = Tire::Index.new('swap_index')
index.create(:mappings => MyModel.tire.mapping_to_hash)
index.import(mymodel_entries)
# and then do some swapping between the old index and the new one, through alias'es
Well, the problem was that I was not passing the settings
to my new index. I was only passing it the mappings
from the MyModel, but not the settings
. So, the right way to do it si this
index.create(:settings => MyMode.tire.settings, :mappings => MyModel.tire.mapping_to_hash)
and this solves the error I was getting.
(My example still does not work in my case because the analyzer might be broken for my case, but I just wanted to help users that might have a similar problem)
Thank you,
Vlad
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.