有时候需要核对分词器是否工作良好,可以使用Indices APIs的Analyze来分析。
官方API示例:

GET _analyze
{
"tokenizer" : "keyword",
"filter" : ["lowercase"],
"text" : "this is a test"
}

Yii的PHP中示例:

/*
* 分析器查看用例 文本是如何被分析的
$params = [
'index' => $this->commonIndex,
'analyzer' => 'number_zh_index_analyzer2',
'text' => '英雄联盟最强王者23'
];
echo json_encode($this->client->indices()->analyze($params));die();
*/

相关资料:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html
https://blog.csdn.net/xifeijian/article/details/51201966

Related Posts: Elasticsearch 查看分词结果 :

avatar