Elasticsearch _analyze, _explain和 _search_shards工具
2015-11-06 10:52
525 查看
_analyze, _explain和_search_shards是Elasticsearch提供的3个辅助API,经常不为人所知和所用。_explain 用来帮助分析文档的relevance
score是如何计算出来的;_search_shards则是用来分析某个搜索请求将会访问到哪些节点以及shard,这在性能调优的时候还是很有用的;而_analyze是Elasticsearch一个非常有用的API,它可以帮助你分析每一个field或者某个analyzer/tokenizer是如何分析和索引一段文字的。
例如, 下面例子用test索引默认analyzer来分析 "this is a test"
GET /test/_analyze?text="this is a test"
执行结果:
{
"tokens": [
{
"token": "this",
"start_offset": 1,
"end_offset": 5,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "is",
"start_offset": 6,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "a",
"start_offset": 9,
"end_offset": 10,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "test",
"start_offset": 11,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 4
}
]
}
你也可以用制定的analyzer来分析,例如:
GET /test/_analyze?analyzer=whitespace&text=this is a test
此外, 你还可以使用指定field的analyzer来分析,例如:
GET/test/_analyze?field=typename.fieldname&text=this is a test
除了上述的API之外, _cat系列API也是常用的系统诊断工具,和curl结合在一起效果就更好了, 参见
Introducing : The cat API.
score是如何计算出来的;_search_shards则是用来分析某个搜索请求将会访问到哪些节点以及shard,这在性能调优的时候还是很有用的;而_analyze是Elasticsearch一个非常有用的API,它可以帮助你分析每一个field或者某个analyzer/tokenizer是如何分析和索引一段文字的。
例如, 下面例子用test索引默认analyzer来分析 "this is a test"
GET /test/_analyze?text="this is a test"
执行结果:
{
"tokens": [
{
"token": "this",
"start_offset": 1,
"end_offset": 5,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "is",
"start_offset": 6,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "a",
"start_offset": 9,
"end_offset": 10,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "test",
"start_offset": 11,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 4
}
]
}
你也可以用制定的analyzer来分析,例如:
GET /test/_analyze?analyzer=whitespace&text=this is a test
此外, 你还可以使用指定field的analyzer来分析,例如:
GET/test/_analyze?field=typename.fieldname&text=this is a test
除了上述的API之外, _cat系列API也是常用的系统诊断工具,和curl结合在一起效果就更好了, 参见
Introducing : The cat API.
相关文章推荐
- Google Apps - Gmail API的通知功能
- svn commit: remains in tree-conflict
- NSSearchPathForDirectoriesInDomains
- HDU 4756 Install Air Conditioning 块与块,非树边最短路
- 谷歌人工智能算法RankBrain运行原理解析
- Leetcode #172 Factorial Trailing Zeroes
- Hibernate的加载抓取方式:Failed to lazily initialize a collection - no session
- golang sync.WaitGroup解决goroutine同步
- Caused by: org.hibernate.TransactionException: unable to commit against JDBC connection
- org.hibernate.TransactionException: commit failed
- Canvas和Paint画折线图
- poj1765 November Rain 扫描线
- nat表中各条chain的工作流程
- anon vma chain
- solrcloud配置dataimport
- 【LeetCode从零单刷】Factorial Trailing Zeroes
- sleep()和 wait()有什么区别
- Hadoop YARN配置参数剖析(4)—Fair Scheduler相关参数
- AIX系统中rmdev删除设备或cfgmgr -v 时无法保存或报错,hd5的问题
- Daily Scrum 11.5