【问题标题】:Elasticsearch Python - Index Analyzer & Search AnalyzerElasticsearch Python - 索引分析器和搜索分析器
【发布时间】:2014-02-25 17:55:49
【问题描述】:

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

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

我找到了更改索引映射的建议,但没有关于如何从 python 执行此操作的文档。

Partial Search using Analyzer in ElasticSearch 显示 n-gram-analyzer 的设置,但没有在 python 中实现它的代码。

【问题讨论】:

    标签: python search elasticsearch


    【解决方案1】:
    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
    )
    

    查看examples here.

    【讨论】:

    猜你喜欢
    • 2023-03-25
    • 2014-02-15
    • 1970-01-01
    • 2018-11-09
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多