Elasticsearch Python-索引分析器&;搜索分析器
我正在使用python api- 如何设置和更改索引的索引分析器和标记器?谢谢 我找到了修改索引映射的建议,但是没有关于如何从python中实现这一点的文档 显示n-gram-analyzer的设置,但没有在python中实现它的代码Elasticsearch Python-索引分析器&;搜索分析器,python,search,
elasticsearch,Python,Search,
elasticsearch,我正在使用python api- 如何设置和更改索引的索引分析器和标记器?谢谢 我找到了修改索引映射的建议,但是没有关于如何从python中实现这一点的文档 显示n-gram-analyzer的设置,但没有在python中实现它的代码 client.indices.create( index=index, body={ 'settings': { # just one shard, no replicas for testing 'nu
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
)
检查如果索引已经存在,则使用
ignore=400将导致此请求以静默方式失败。在这种情况下,您可能希望看到一个错误:)@DrTech添加了更多信息。如何使用python实现这一点?