Official docker image bug - cannot resolve config path


(Alexander Skiller) #1

I am using official elasticsearch docker image to run my elasticsearch instance.
I am trying to create an index with some filters which require to load some files (synonym filter, stopword filter...) none of such filters works because I get errors such as this one:

{
   "error": "RemoteTransportException[[Hood][inet[/172.17.0.6:9300]][indices:admin/create]]; nested: IndexCreationException[[admin] failed to create index]; nested: FailedToResolveConfigException[Failed to resolve config path [/usr/share/elasticsearch/config/synonyms/sk_SK.txt], tried file path [/usr/share/elasticsearch/config/synonyms/sk_SK.txt], path file [/opt/logstash/config/usr/share/elasticsearch/config/synonyms/sk_SK.txt], and classpath]; ",
   "status": 500
}

this is my code to create the index:

POST /admin
{
   "settings": {
      "analysis": {
         "filter": {
           "synonym_filter": {
              "type": "synonym",
              "synonyms_path": "/usr/share/elasticsearch/config/synonyms/sk_SK.txt",
              "ignore_case": true
           },
           "sk_SK" : {
              "type" : "hunspell",
              "locale" : "sk_SK",
              "dedup" : true,
              "recursion_level" : 0
            },
            "nGram_filter": {
               "type": "nGram",
               "min_gram": 2,
               "max_gram": 20,
               "token_chars": [
                  "letter",
                  "digit",
                  "punctuation",
                  "symbol"
               ]
            }
         },
         "analyzer": {
            "slovencina_synonym": {
              "type": "custom",
              "tokenizer": "standard",
              "filter": [
                "lowercase",
                "synonym_filter",
                "asciifolding"
                ]
            },
            "slovencina": {
              "type": "custom",
              "tokenizer": "standard",
              "filter": [
                "lowercase",
                "asciifolding"
                ]
            },
            "nGram_analyzer": {
               "type": "custom",
               "tokenizer": "whitespace",
               "filter": [
                  "lowercase",
                  "asciifolding",
                  "nGram_filter"
               ]
            },
            "whitespace_analyzer": {
               "type": "custom",
               "tokenizer": "whitespace",
               "filter": [
                  "lowercase",
                  "asciifolding"
               ]
            }
         }
      }
   }
}

The file is there on that path of course inside this docker container.

I was googling the error and I have read some posts that the problem is in file/folder permissions, so I tried the following:

sudo chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/config/*
chmod o+x /usr
chmod o+x /usr/share
chmod o+x /usr/share/elasticsearch
chmod o+x /usr/share/elasticsearch/config/

still did not work after this.

Since this is happening inside docker container which is using official docker elasticsearch image, I consider this as a bug and this should work out of the box, yet I did not find any solution for this. I would appreciate if anyone could post some workaround.


(David Pilato) #2

Just a note about that. This is not official from elastic side as far as I know.
Looking at the contributor list, no one is working for elastic. And the title for this repo is: "Docker Official Image packaging for elasticsearch".

As I wrote in the issue:

May be your docker instance does not have access to this file?

Failed to resolve config path [/usr/share/elasticsearch/config/synonyms/sk_SK.txt], 
tried file path [/usr/share/elasticsearch/config/synonyms/sk_SK.txt], 
path file [/opt/logstash/config/usr/share/elasticsearch/config/synonyms/sk_SK.txt], 
and classpath

Is it something you can test when your docker image is running? Something like: ls -l /usr/share/elasticsearch/config/synonyms/sk_SK.txt


(Alexander Skiller) #3

thank you for your reply,

My docker instance seems to have access to that file

elasticsearch@8e3d64135f9d:~/config/synonyms$ ls -la
drwxr-xr-x 2 elasticsearch elasticsearch   4096 Sep 10 11:42 .
drwxr-xr-x 9 elasticsearch elasticsearch   4096 Sep 10 11:43 ..
-rw-r--r-- 1 elasticsearch elasticsearch 168636 Sep  9 17:15 sk_SK.txt

I can even do cat /usr/share/elasticsearch/config/synonyms/sk_SK.txt
and it will show its contents. Both as elasticsearch user or root.


(David Pilato) #4

Interesting. Any chance you can try the exact same configuration but without Docker?

So we can then understand where we should look at?


(Alexander Skiller) #5

I just tried it in a freshly installed ubuntu server 14.04 inside virtualbox and downloaded and installed java and elasticsearch manually, then I run it, and it works. I am able to create that index. It can successfully load that file from that path. So I suspect the problem is still somewhere on user permission level. I will try to create custom docker image for this, to solve this.


(David Pilato) #6

Thank you for testing!


(Alexander Skiller) #7

So I created my custom docker image from scratch, from pure ubuntu, and tried to set it purely like the virtual machine I have set up. But it did not still work. I was frustrated but I found out that the problem is in LOGSTASH

LOGSTASH is running separately as another docker container in my environment and it somehow automatically communicates with ElasticSearch docker image (they are linked). As soon as I killed Logstash container, the query says:

{
   "acknowledged": true
}

I guess when these two (logstash & ES) are running on the same network and are communicating, ES is expecting some path to exist /opt/logstash/config/usr/share/elasticsearch/config/synonyms/sk_SK.txt
which it doesn't on my ES container.
/opt/logstash folder does not exist, should it? Why doesn't ES create it automatically if it needs it? I don't understand.


(David Pilato) #8

Most likely you are using logstash with a NodeClient.
It joins the cluster.

Use logstash with http output.

That should help.


(Alexander Skiller) #9

please could you tell me how do I make logstash stop connecting to elasticsearch? I guess it's elasticsearch feature the autodiscovering of nodes, but I don't know what should be done in order to stop accepting logstah as a node. I want to auto-accept ES nodes that's ok. But no no for logstash

If this helps, this is my config I use to move logs from node.js to ES via logstash

input {
  tcp { port => 9292 type=>"sample" }
}

filter {
  json {
    source => "message"
  }
}

output {
  elasticsearch {
    host => "192.168.59.103"
    port => "9200"
    protocol => "http"
  }
  stdout {}
}

(system) #10