Elasticsearch Python - 索引分析器和搜索分析器

Pra*_*dar 6 python search elasticsearch

我正在使用python api - http://elasticsearch-py.readthedocs.org

如何设置更改索引的索引分析器和标记化器?谢谢

我找到了改变索引映射的建议,但是没有关于如何从python中做到这一点的文档.

在ElasticSearch使用Analyzer进行部分搜索显示n-gram-analyzer的设置,但没有代码在python中实现它.

Nat*_*han 11

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
)
Run Code Online (Sandbox Code Playgroud)

这里查看示例.