简体   繁体   English

创建索引的Elasticsearch问题(Rails)

[英]Elasticsearch issue with creating index (Rails)

I am experiencing an issue with creating an index for my Product model class. 我在为我的产品模型类创建索引时遇到问题。 This happens since I added hunspell filter and am not able to figure out what's wrong. 这是因为我添加了hunspell过滤器而无法找出问题所在。

I will appreciate any hint. 我将不胜感激。

Thank you, Miroslav 谢谢米罗斯拉夫


Configuration: 组态:

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

Log output: 日志输出:

[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

Console output: 控制台输出:

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>'

@SsouLlesS I plan to move it to reTire, but later, not now as we need to launch the first product out asap. @SsouLlesS我计划将其移至退休,但后来,不是现在,因为我们需要尽快推出第一个产品。 Anyway I was able to fix the issue described above. 无论如何,我能够解决上述问题。 The hunspell cs-CZ libraries were broken for some reason and when I imported the fixed versions (taken from https://issues.apache.org/jira/browse/LUCENE-4311 ), the issue has disappeared and it works as expected. hunspell cs-CZ库由于某种原因而损坏,当我导入固定版本(取自https://issues.apache.org/jira/browse/LUCENE-4311 )时,该问题已消失并且按预期运行。 Thank you for your time and tip. 谢谢您的时间和小费。 Miroslav 米罗斯拉夫

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM