Elasticearch Python - Index Analyzer and Search Analyzer

I am using python api - http://elasticsearch-py.readthedocs.org

How can I change the index analyzer and tokenizer for the index? Thanks

I found suggestions for changing the index display, but there was no documentation on how to do this from python.

Partial search using Analyzer in ElasticSearch shows the settings for the n-gram analyzer, but does not contain code for its implementation in python.

+4
source share
1 answer
client.indices.create(
    index=index,
    body={
      'settings': {
        # just one shard, no replicas for testing
        'number_of_shards': 1,
        'number_of_replicas': 0,

        # custom analyzer for analyzing file paths
        'analysis': {
          'analyzer': {
            'file_path': {
              'type': 'custom',
              'tokenizer': 'path_hierarchy',
              'filter': ['lowercase']
            }
          }
        }
      }
    },
    # Will ignore 400 errors, remove to ensure you're prompted
    ignore=400
)

Look at here .

+7
source

Source: https://habr.com/ru/post/1524903/


All Articles