2016-02-20 2 views
0

У меня возникла проблема с созданием индекса для моего класса модели продукта. Это происходит, так как я добавил фильтр hunspell и не могу понять, что не так.Проблема с Elasticsearch с созданием индекса (Rails)

Буду признателен за любые подсказки.

Спасибо, Мирослав


Конфигурация:

settings index: { 
number_of_shards: 5, 
analysis: { 
    filter: { 
    trigrams_filter: { 
     type: 'ngram', 
     min_gram: 2, 
     max_gram: 10 
    }, 
    content_filter: { 
     type: 'ngram', 
     min_gram: 4, 
     max_gram: 20 
    }, 
    hunspell_CZ: { 
     type: 'hunspell', 
     locale: 'cs_CZ', 
     dedup: true, 
     recursion_level: 0 
    }, 
    czechStemmer: { 
     type: 'stemmer', 
     name: 'czech' 
    }, 
    customWordDelimiter: { 
     type: 'word_delimiter', 
     generate_word_parts: true, 
     generate_number_parts: true, 
     catenate_words: true, 
     catenate_numbers: true, 
     catenate_all: true, 
     split_on_case_change: true, 
     preserve_original: true, 
     split_on_numerics: true, 
     stem_english_possessive: false 
    }, 
    customUnique: { 
     type: 'unique', 
     only_on_same_position: false 
    } 
    }, 
    analyzer: { 
    myFulltextAnalyzer: { 
     type: 'custom', 
     tokenizer: 'standard', 
     filter: ['lowercase', 'hunspell_CZ', 'icu_folding', 'customWordDelimiter', 'czechStemmer', 'customUnique'], 
     char_filter: ['html_strip'] 
    }, 
    index_trigrams_analyzer: { 
     type: 'custom', 
     tokenizer: 'standard', 
     filter: ['lowercase', 'trigrams_filter', 'asciifolding'] 
    }, 
    search_trigrams_analyzer: { 
     type: 'custom', 
     tokenizer: 'whitespace', 
     filter: ['lowercase'] 
    }, 
    english: { 
     tokenizer: 'standard', 
     filter: ['standard', 'lowercase', 'content_filter'] 
    }, 
    czech: { 
     tokenizer: 'standard', 
     filter: ['asciifolding','standard','lowercase','content_filter'] 
    } 
    } 
} 
} do 
mappings dynamic: 'false' do 
    indexes :id, type: 'integer' 
    indexes :active, type: 'boolean' 
    indexes :en_product, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :ma_product, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :cs_product, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :en_description, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :ma_description, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :cs_description, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :en_specification, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :ma_specification, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :cs_specification, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
    indexes :manufacturer, index_analyzer: 'myFulltextAnalyzer', search_analyzer: 'myFulltextAnalyzer' 
end 
end 

Выход Вход:

[2016-02-20 13:58:03,083][DEBUG][action.admin.indices.create] [db1] [products] failed to create 
org.elasticsearch.indices.IndexCreationException: [products] failed to create index 
    at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:338) 
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:371) 
    at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:374) 
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:204) 
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:167) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.elasticsearch.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: expected ']' at position 46 

Консоль вывода:

2.2.0 :001 > Product.__elasticsearch__.create_index! force: true 
2016-02-20 13:57:40 +0100: DELETE http://51.255.133.242:9200/products [status:404, request:0.010s, query:N/A] 
2016-02-20 13:57:40 +0100: < {"error":"RemoteTransportException[[db1][inet[/10.250.0.30:9300]][indices:admin/delete]]; nested: IndexMissingException[[products] missing]; ","status":404} 
2016-02-20 13:57:40 +0100: [404] {"error":"RemoteTransportException[[db1][inet[/10.250.0.30:9300]][indices:admin/delete]]; nested: IndexMissingException[[products] missing]; ","status":404} 
[!!!] Index does not exist (Elasticsearch::Transport::Transport::Errors::NotFound) 
2016-02-20 13:57:40 +0100: HEAD http://51.255.133.242:9200/products [status:404, request:0.006s, query:N/A] 
2016-02-20 13:57:40 +0100: < 
2016-02-20 13:57:40 +0100: [404] 
2016-02-20 13:57:42 +0100: PUT http://51.255.133.242:9200/products [status:500, request:1.565s, query:N/A] 
2016-02-20 13:57:42 +0100: > {"settings":{"index":{"number_of_shards":5,"analysis":{"filter":{"trigrams_filter":{"type":"ngram","min_gram":2,"max_gram":10},"content_filter":{"type":"ngram","min_gram":4,"max_gram":20},"hunspell_CZ":{"type":"hunspell","locale":"cs_CZ","dedup":true},"czechStemmer":{"type":"stemmer","name":"czech"},"customWordDelimiter":{"type":"word_delimiter","generate_word_parts":true,"generate_number_parts":true,"catenate_words":true,"catenate_numbers":true,"catenate_all":true,"split_on_case_change":true,"preserve_original":true,"split_on_numerics":true,"stem_english_possessive":false},"customUnique":{"type":"unique","only_on_same_position":false}},"analyzer":{"myFulltextAnalyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","hunspell_CZ","icu_folding","customWordDelimiter","czechStemmer","customUnique"],"char_filter":["html_strip"]},"index_trigrams_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","trigrams_filter","asciifolding"]},"search_trigrams_analyzer":{"type":"custom","tokenizer":"whitespace","filter":["lowercase"]},"english":{"tokenizer":"standard","filter":["standard","lowercase","content_filter"]},"czech":{"tokenizer":"standard","filter":["asciifolding","standard","lowercase","content_filter"]}}}}},"mappings":{"product":{"dynamic":"false","properties":{"id":{"type":"integer"},"active":{"type":"boolean"},"en_product":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"ma_product":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"cs_product":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"en_description":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"ma_description":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"cs_description":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"en_specification":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"ma_specification":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"cs_specification":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"},"manufacturer":{"index_analyzer":"myFulltextAnalyzer","search_analyzer":"myFulltextAnalyzer","type":"string"}}}}} 
2016-02-20 13:57:42 +0100: < {"error":"RemoteTransportException[[db1][inet[/10.250.0.30:9300]][indices:admin/create]]; nested: IndexCreationException[[products] failed to create index]; nested: UncheckedExecutionException[java.lang.IllegalArgumentException: expected ']' at position 46]; nested: IllegalArgumentException[expected ']' at position 46]; ","status":500} 
2016-02-20 13:57:42 +0100: [500] {"error":"RemoteTransportException[[db1][inet[/10.250.0.30:9300]][indices:admin/create]]; nested: IndexCreationException[[products] failed to create index]; nested: UncheckedExecutionException[java.lang.IllegalArgumentException: expected ']' at position 46]; nested: IllegalArgumentException[expected ']' at position 46]; ","status":500} 
Elasticsearch::Transport::Transport::Errors::InternalServerError: [500] {"error":"RemoteTransportException[[db1][inet[/10.250.0.30:9300]][indices:admin/create]]; nested: IndexCreationException[[products] failed to create index]; nested: UncheckedExecutionException[java.lang.IllegalArgumentException: expected ']' at position 46]; nested: IllegalArgumentException[expected ']' at position 46]; ","status":500} 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-transport-1.0.13/lib/elasticsearch/transport/transport/base.rb:136:in `__raise_transport_error' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-transport-1.0.13/lib/elasticsearch/transport/transport/base.rb:228:in `perform_request' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-transport-1.0.13/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-transport-1.0.13/lib/elasticsearch/transport/client.rb:119:in `perform_request' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-api-1.0.13/lib/elasticsearch/api/namespace/common.rb:21:in `perform_request' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/elasticsearch-api-1.0.13/lib/elasticsearch/api/actions/indices/create.rb:77:in `create' 
from /opt/deploy/shared/bundle/ruby/2.2.0/bundler/gems/elasticsearch-rails-ded203569208/elasticsearch-model/lib/elasticsearch/model/indexing.rb:228:in `create_index!' 
from (irb):1 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/console.rb:110:in `start' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in `start' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in `console' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
from /opt/deploy/shared/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>' 
from bin/rails:4:in `require' 
from bin/rails:4:in `<main>' 
+0

Вы используете самый сложный способ для интеграции Elasticsearch в свое приложение rails, думаете ли вы, что использовать reTire gem? – SsouLlesS

ответ

0

@SsouLlesS Я планирую переместить его в reTire, но позже, а не сейчас, поскольку нам нужно запустить первый продукт как можно скорее. В любом случае я смог исправить проблему, описанную выше. По какой-то причине библиотеки cs-CZ hunspell были повреждены, и когда я импортировал фиксированные версии (взятые с https://issues.apache.org/jira/browse/LUCENE-4311), проблема исчезла и работает так, как ожидалось. Спасибо за ваше время и подсказку. Miroslav

 Смежные вопросы

  • Нет связанных вопросов^_^