gpt4 book ai didi

elasticsearch - 如何从Elasticsearch获取自定义分析器源?

转载 作者:行者123 更新时间:2023-12-03 02:03:08 25 4
gpt4 key购买 nike

我向elasticsearch发出了_mapping请求,并看到一个字段使用了自定义分析器。像这样的字段的输出:

"myFieldName": {
"type": "string",
"analyzer": "someCustomAnalyzer"
}

那么有没有办法获取该 someCustomAnalyzer的源代码?我已尝试请求 curl -XGET localhost:9200/_analyze?analyzer=someCustomAnalyzer并得到:
{
"error": "ElasticsearchIllegalArgumentException[text is missing]",
"status": 400
}

如果我为查询字符串添加 text参数,我将获得分析结果以进行分析,但是我需要分析器定义。

最佳答案

您可以使用settings看到它。现在,它在1.5版中的可读性比以前更高。

因此,如果我使用非平凡的分析器创建索引:

PUT /test_index
{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"edge_ngram_filter"
]
}
}
}
},
"mappings": {
"doc": {
"_all": {
"enabled": true,
"index_analyzer": "edge_ngram_analyzer",
"search_analyzer": "standard"
},
"properties": {
"first_name": {
"type": "string",
"include_in_all": true
},
"last_name": {
"type": "string",
"include_in_all": true
},
"ssn": {
"type": "string",
"index": "not_analyzed",
"include_in_all": true
}
}
}
}
}

我可以通过以下方式获取索引设置:
GET /test_index/_settings
...
{
"test_index": {
"settings": {
"index": {
"creation_date": "1430394627755",
"uuid": "78oYlYU9RS6LZ5YFyeaMRQ",
"analysis": {
"filter": {
"edge_ngram_filter": {
"min_gram": "2",
"type": "edge_ngram",
"max_gram": "20"
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"edge_ngram_filter"
],
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"number_of_shards": "1",
"version": {
"created": "1050099"
}
}
}
}
}

这是我使用的代码:

http://sense.qbox.io/gist/4a38bdb0cb7d381caa29b9ce2c3c154b63cdc1f8

关于elasticsearch - 如何从Elasticsearch获取自定义分析器源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29966390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com