# Базовые настройки индекса для работы с русской морфологией

**URL:** https://discuss.elastic.co/t/topic/56395
**Category:** Вопросы на русском языке
**Created:** [July 26, 2016, 12:45pm UTC](https://discuss.elastic.co/t/topic/56395 "2016-07-26T12:45:59Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [July 26, 2016, 12:45pm UTC](https://discuss.elastic.co/t/topic/56395/1 "2016-07-26T12:45:59Z")

</div>

Всем привет!

Это мой первый пост на данном ресурсе. Пишу т.к. уже отчаялся )

Уже неделю играю с elasticsearch.  
Поднял сервер на debian, разобрался с sence, kibana, написал даже программку на node.js , которая по одной кнопке создает индекс и записи, по другой - вытягивает содержимое и выводит на экран.

Но по прежнему являюсь совершенным профаном в этом деле.

Моя проблема на данный момент - как правильно задать настройки для индекса.

Нашел вот эту статью - [http://obtao.com/blog/2013/10/configure-elasticsearch-on-an-efficient-way/](http://obtao.com/blog/2013/10/configure-elasticsearch-on-an-efficient-way/)

Если убрать фичи для французского - то все ли там нормально? Можно их использовать?  
Я только учусь и недавно от SQL ушел. Тяжко со всеми этими JSON пока что...  
Уже много раз пересоздал свой индекс. Хочу чтоб морфология русская заработала.

В доках так и не нашел образца как задаются данные настройки.  
Надо все что перечислено в статье перевести в формат JSON и как по образцу вставить?

curl -XPOST 'localhost:9200/myindex/\_close'

```
curl -XPUT 'localhost:9200/myindex/_settings' -d '{
  "analysis" : {
    "analyzer":{
      "content":{
        "type":"custom",
        "tokenizer":"whitespace"
      }
    }
  }
}'

```

curl -XPOST 'localhost:9200/myindex/\_open'

Так же не очень понимаю зачем надо открывать и закрывать индекс.

---

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [July 26, 2016, 1:22pm UTC](https://discuss.elastic.co/t/topic/56395/2 "2016-07-26T13:22:46Z")

</div>

В данный момент воюю вот с такой ошибкой при попытке создать ru\_analyzer:

```
{
   "error": {
      "root_cause": [
         {
            "type": "index_creation_exception",
            "reason": "failed to create index"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "Custom Analyzer [ru_analyzer] failed to find filter under name [my_stopwords]"
   },
   "status": 400
}

```

Порядок моих действий:

```
PUT /my_index/
{
    "settings" : {
        "index" : {
            "number_of_shards" : 5,
            "number_of_replicas" : 1
        }
    }
}

POST /my_index/_close

PUT /my_index/_settings
{
  "analysis" : {
        "analyzer": {
          "ru_analyzer": {
             "filter": [
                "lowercase",
        		"russian_morphology",
        		"english_morphology",
        		"my_stopwords"
        	 ],
        	 "type": "custom",
        	 "tokenizer": "standard"
          }
        }
    }
  }

POST /my_index/_open

PUT my_index/_mapping/full_instance_of_class
{
    "properties": {
        "instance_id": {
          "type": "string",
          "store": true,
          "analyzer": "ru_analyzer"
        },
        "listOfFields": {
            "properties": {
                "field_id": {
                      "type": "string",
                      "store": true,
                      "analyzer": "ru_analyzer"
                },
                "field_text": {
                      "type": "string",
                      "store": true,
                      "analyzer": "ru_analyzer"
                }
              }
            }
    }
}

```

После всех команд результат был

{  
"acknowledged": true  
}

---

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [July 26, 2016, 1:47pm UTC](https://discuss.elastic.co/t/topic/56395/3 "2016-07-26T13:47:55Z")

</div>

С тестовым примером тоже какие то проблемы у меня

> <https://github.com/imotov/elasticsearch-analysis-morphology/blob/master/demo.sh>

На

```
PUT /rustest/type1/_mapping
{
    "type1": {
	    "_all" : {"analyzer" : "russian_morphology"},
    	"properties" : {
        	"body" : { "type" : "string", "analyzer" : "russian_morphology" }
    	}
	}
}

```

Выдает мне

```
{
   "error": {
      "root_cause": [
         {
            "type": "process_cluster_event_timeout_exception",
            "reason": "failed to process cluster event (put-mapping [type1]) within 30s"
         }
      ],
      "type": "process_cluster_event_timeout_exception",
      "reason": "failed to process cluster event (put-mapping [type1]) within 30s"
   },
   "status": 503
}

```

Плагин установил

Downloading .DONE  
ERROR: plugin directory /elasticsearch/elasticsearch-2.3.3/plugins/elasticsearch-analysis-morphology already exists. To update the plugin, uninstall it first using 'remove elasticsearch-analysis-morphology' command

---

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [July 26, 2016, 3:15pm UTC](https://discuss.elastic.co/t/topic/56395/4 "2016-07-26T15:15:59Z")

</div>

хм. а если просто выполнить сам .sh тестовый - то все ок... только localhost на свой ip поменял...

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [July 26, 2016, 3:22pm UTC](https://discuss.elastic.co/t/topic/56395/5 "2016-07-26T15:22:37Z")

</div>

Из вашего запроса надо убрать фильтр my\_stopwords, который у вас не определен, или определить его, как в примере [demo.sh](http://demo.sh).

```auto
PUT /my_index/_settings
{
  "analysis" : {
        "analyzer": {
          "ru_analyzer": {
             "filter": [
                "lowercase",
        		"russian_morphology",
        		"english_morphology"
        	 ],
        	 "type": "custom",
        	 "tokenizer": "standard"
          }
        }
    }
  }

```

---

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [July 26, 2016, 3:25pm UTC](https://discuss.elastic.co/t/topic/56395/6 "2016-07-26T15:25:33Z")

</div>

Спасибо огромное за быстрый ответ!!!

---

<div class="post-metadata">

### Author: ![SealTecH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sealtech/32/16607_2.png) [@SealTecH](https://discuss.elastic.co/u/SealTecH)
#### Post date: [March 22, 2017, 3:27pm UTC](https://discuss.elastic.co/t/topic/56395/8 "2017-03-22T15:27:33Z")

</div>

Добрый день, столкнулся с той же проблемой:

```
{"error":
  {"root_cause":[{
                   "type":"illegal_argument_exception",
                  "reason":"Custom Analyzer [ru_analyzer] failed to find filter under name [russian_morphology]"
                }],
   "type":"illegal_argument_exception",
    "reason":"Custom Analyzer [ru_analyzer] failed to find filter under name [russian_morphology]"
   },"status":400
}

```

При выполнении команды

```
 curl -XPUT 'http://localhost:9200/rustest' -d 
'{"settings":
   { "analysis" : { 
            "analyzer": {    
              "ru_analyzer": {       
              "filter": ["lowercase", "russian_morphology", "english_morphology"], 
              "type": "custom",
       	      "tokenizer": "standard"   
                              }        
                         }   
                    }  
 }  
}'

```

Проверял, плагин установлен, сервис перезапускал, версия 5.2.2  
Буду благодарен за помощь)

---

<div class="post-metadata">

### Author: ![whispersofdew](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whispersofdew/32/11067_2.png) [@whispersofdew](https://discuss.elastic.co/u/whispersofdew)
#### Post date: [March 22, 2017, 3:49pm UTC](https://discuss.elastic.co/t/topic/56395/9 "2017-03-22T15:49:30Z")

</div>

> [@SealTecH](#):
>
> ```
> curl -XPUT 'http://localhost:9200/rustest' -d 
> '{"settings":
> { "analysis" : { 
> "analyzer": {    
> "ru_analyzer": {       
> "filter": ["lowercase", "russian_morphology", "english_morphology"], 
> "type": "custom",
> "tokenizer": "standard"   
> }        
> }   
> }  
> }  
> }'
> 
> ```

через Кибану (плагин sense) на эластике 2.3.3 ваш код отработал.

`curl localhost:9200/_nodes/plugins?pretty`

вернул помимо прочего

```
{
  "name": "elasticsearch-analysis-morphology",
  "version": "2.3.3",
  "description": "Russian Morphology for ElasticSearch",
  "jvm": true,
  "classname": "org.elasticsearch.plugin.analysis.morphology.AnalysisMorphologyPlugin",
  "isolated": true,
  "site": false
}

```

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [March 22, 2017, 3:50pm UTC](https://discuss.elastic.co/t/topic/56395/10 "2017-03-22T15:50:22Z")

</div>

А что говорит

```auto
curl localhost:9200/_nodes/plugins?pretty

```

---

<div class="post-metadata">

### Author: ![SealTecH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sealtech/32/16607_2.png) [@SealTecH](https://discuss.elastic.co/u/SealTecH)
#### Post date: [March 22, 2017, 5:02pm UTC](https://discuss.elastic.co/t/topic/56395/11 "2017-03-22T17:02:59Z")

</div>

говорит, что массив плагинов пустой. При этом

```
sudo bin/elasticsearch-plugin list 

```

выводит

```
 analysis-morphology

```

устанавливал, используя урл из гитхаба

```
bin/elasticsearch-plugin install http://dl.bintray.com/content/imotov/elasticsearch-plugins/org/elasticsearch/elasticsearch-analysis-morphology/5.2.2/elasticsearch-analysis-morphology-5.2.2.zip

```

попробовал ещё раз

```
ERROR: plugin directory [/home/gjrjhbntkbvbhjd0/elasticsearch-5.2.2/plugins/analysis-morphology] already exists;
 if you need to update the plugin, uninstall it first using command 'remove analysis-morphology'

```

Вот полный лог команды

> **\_nodes/plugins?pretty**
>
> ```
> {
> "_nodes" : {
> "total" : 1,
> "successful" : 1,
> "failed" : 0
> },
> "cluster_name" : "elasticsearch",
> "nodes" : {
> "i2SnF0yuTHaWm7m18jRCTg" : {
> "name" : "i2SnF0y",
> "transport_address" : "10.132.0.2:9300",
> "host" : "10.132.0.2",
> "ip" : "10.132.0.2",
> "version" : "5.2.2",
> "build_hash" : "f9d9b74",
> "roles" : [
> "master",
> "data",
> "ingest"
> ],
> "plugins" : [],
> "modules" : [
> {
> "name" : "aggs-matrix-stats",
> "version" : "5.2.2",
> "description" : "Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
> "classname" : "org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin"
> },
> {
> "name" : "ingest-common",
> "version" : "5.2.2",
> "description" : "Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
> "classname" : "org.elasticsearch.ingest.common.IngestCommonPlugin"
> },
> {
> "name" : "lang-expression",
> "version" : "5.2.2",
> "description" : "Lucene expressions integration for Elasticsearch",
> "classname" : "org.elasticsearch.script.expression.ExpressionPlugin"
> },
> {
> "name" : "lang-groovy",
> "version" : "5.2.2",
> "description" : "Groovy scripting integration for Elasticsearch",
> "classname" : "org.elasticsearch.script.groovy.GroovyPlugin"
> },
> {
> "name" : "lang-mustache",
> "version" : "5.2.2",
> "description" : "Mustache scripting integration for Elasticsearch",
> "classname" : "org.elasticsearch.script.mustache.MustachePlugin"
> },
> {
> "name" : "lang-painless",
> "version" : "5.2.2",
> "description" : "An easy, safe and fast scripting language for Elasticsearch",
> "classname" : "org.elasticsearch.painless.PainlessPlugin"
> },
> {
> "name" : "percolator",
> "version" : "5.2.2",
> "description" : "Percolator module adds capability to index queries and query these queries by specify
> ing documents",
> "classname" : "org.elasticsearch.percolator.PercolatorPlugin"
> },
> {
> "name" : "reindex",
> "version" : "5.2.2",
> "description" : "The Reindex module adds APIs to reindex from one index to another or update documents
> in place.",
> "classname" : "org.elasticsearch.index.reindex.ReindexPlugin"
> },
> {
> "name" : "transport-netty3",
> "version" : "5.2.2",
> "description" : "Netty 3 based transport implementation",
> "classname" : "org.elasticsearch.transport.Netty3Plugin"
> },
> {
> "name" : "transport-netty4",
> "version" : "5.2.2",
> "description" : "Netty 4 based transport implementation",
> "classname" : "org.elasticsearch.transport.Netty4Plugin"
> }
> ]
> }
> }
> }
> 
> ```

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [March 22, 2017, 5:19pm UTC](https://discuss.elastic.co/t/topic/56395/12 "2017-03-22T17:19:17Z")

</div>

А какие пути указаны в секции `path` в

```auto
curl "localhost:9200/_nodes/settings?pretty"

```

---

<div class="post-metadata">

### Author: ![SealTecH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sealtech/32/16607_2.png) [@SealTecH](https://discuss.elastic.co/u/SealTecH)
#### Post date: [March 22, 2017, 5:32pm UTC](https://discuss.elastic.co/t/topic/56395/13 "2017-03-22T17:32:36Z")

</div>

```
{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "i2SnF0yuTHaWm7m18jRCTg" : {
      "name" : "i2SnF0y",
      "transport_address" : "10.132.0.2:9300",
      "host" : "10.132.0.2",
      "ip" : "10.132.0.2",
      "version" : "5.2.2",
      "build_hash" : "f9d9b74",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "settings" : {
        "pidfile" : "/var/run/elasticsearch/elasticsearch.pid",
        "cluster" : {
          "name" : "elasticsearch"
        },
        "node" : {
          "name" : "i2SnF0y"
        },
        "path" : {
          "conf" : "/etc/elasticsearch",
          "data" : [
            "/var/lib/elasticsearch"
          ],
          "logs" : "/var/log/elasticsearch",
          "home" : "/usr/share/elasticsearch"
        },
        "client" : {
          "type" : "node"
        },
        "http" : {
          "type" : {
            "default" : "netty4"
          }
        },
        "transport" : {
          "type" : {
            "default" : "netty4"
          }
        },
        "network" : {
          "host" : "10.132.0.2"
        }
      }
    }
  }
}

```

Запускаю я его с

home/username/elasticsearch-5.2.2

при установке следовал инструкции с сайта. Загрузил:

```
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.zip

```

и запустил

```
./bin/elasticsearch
```

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [March 22, 2017, 6:34pm UTC](https://discuss.elastic.co/t/topic/56395/14 "2017-03-22T18:34:29Z")

</div>

Похоже, что у вас на этой машине стоит (или стояла) другая версия elasticsearch проинсталлированная из rpm или deb. От нее остались конфигурационный файлы в `/etc/elasticsearch`, которые подхватываются скриптом elasticsearch но не скриптом elasticsearch-plugin. Поэтому плагины инсталируются в `/home/gjrjhbntkbvbhjd0/elasticsearch-5.2.2/plugins/`, а читаются из `/usr/share/elasticsearch/plugins/`

---

<div class="post-metadata">

### Author: ![SealTecH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sealtech/32/16607_2.png) [@SealTecH](https://discuss.elastic.co/u/SealTecH)
#### Post date: [March 22, 2017, 8:45pm UTC](https://discuss.elastic.co/t/topic/56395/15 "2017-03-22T20:45:04Z")

</div>

По всей видимости проблема была именно в этом. Я на всякий случай перебил систему (машина была специально под поиск), и установил заново с помощью Deb, и всё отлично заработало.

Спасибо большое за уделённое время и быстрый ответ)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:43pm UTC](https://discuss.elastic.co/t/topic/56395/16 "2017-07-06T13:43:43Z")

</div>


