Search code examples
djangoherokuelasticsearchbonsai-elasticsearch

Bonsai ElasticSearch + Heroku + Python - Location of Synonym File


I'm using bonsai.io and want to point elasticsearch to my synonyms file.

I have kept the wn_s.pl in a folder on heroku and the django app can see the file:

>>> call(['ls', '-l', os.path.join(settings.BASE_DIR, 'data', 'wn_s.pl')])
-rwx------ 1 u37195 37195 7494480 2014-09-30 17:24 /app/data/wn_s.pl

But when I am creating index with the filter as:

'filter': {
          'my_filter': {
                       'type': 'synonym',
                       'format': 'wordnet',
                       'synonyms_path': os.path.join(settings.BASE_DIR, 'data', 'wn_s.pl')
                       }
          }

I get the error as:

TransportError: TransportError(500, u'IndexCreationException[[article-index] failed to create index]; nested: FailedToResolveConfigException[Failed to resolve config path [/app/data/wn_s.pl], tried file path [/app/data/wn_s.pl], path file [/opt/elasticsearch/current/config/app/data/wn_s.pl], and classpath]; ')

How should I fix it?

Thanks


Solution

  • As per the docs, synonyms_path is relative to the ES config file: http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/analysis-synonym-tokenfilter.html