作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我向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"
}
}
}
}
}
关于elasticsearch - 如何从Elasticsearch获取自定义分析器源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29966390/
我是一名优秀的程序员,十分优秀!