index test的 mapping 定义:
"content": {
"type": "text",
"analyzer": "ik_smart"
},
"title": {
"type": "text",
"analyzer": "ik_smart"
}
测试分词:
http://127.0.0.1:9200/_analyze
提交参数:
{
"text": "中国美国英国",
"analyzer": "ik_smart"
}
返回
{
"tokens": [
{
"token": "中国",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 0
},
{
"token": "美国",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 1
},
{
"token": "英国",
"start_offset": 4,
"end_offset": 6,
"type": "CN_WORD",
"position": 2
}
]
}
_search 测试一下索引 test
get body
{
"size": 20,
"query": {
"match": {
"content": "广州人"
}
}
}
返回:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.84268904,
"hits": [
{
"_index": "dcc-speechcrafts",
"_type": "dcc-speechcraft",
"_id": "AXIyjmXuVhRXxkRgwNlT",
"_score": 0.84268904,
"_source": {
"title": "",
"content": "qefdygyrfh 广州人"
}
}
]
}
}
第二次_search 测试一下
get body
{
"size": 20,
"query": {
"match": {
"content": "广州"
}
}
}
返回:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
问题,我那条记录内容包含广州人这三个字,为什么分别用广州人和广州两个词去查询,一次有结果,一次没结果呀?按道理用广州去查询应该也是返回一样的结果的呀,这什么问题?
elasticsearch 5.6.16
