Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

如何以词进行命中 而不是字? #20

Closed
yyhjifeng opened this issue Sep 6, 2018 · 3 comments
Closed

如何以词进行命中 而不是字? #20

yyhjifeng opened this issue Sep 6, 2018 · 3 comments

Comments

@yyhjifeng
Copy link

http://localhost:9200/jieba_index/fulltext/_search
{
"query" : { "match" : { "content" : "大学" }},
"highlight" : {
"pre_tags" : ["", ""],
"post_tags" : ["", ""],
"fields" : {
"content" : {}
}
}
}

得到结果:

{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.68324494,
"hits": [
{
"_index": "jieba_index",
"_type": "fulltext",
"_id": "2",
"_score": 0.68324494,
"_source": {
"content": "中国的伟大时代来临了,欢迎参观北京大学PKU"
},
"highlight": {
"content": [
"中国的伟大时代来临了,欢迎参观北京大学PKU"
]
}
}
]
}
}

我想要的是:
"中国的伟大时代来临了,欢迎参观北京大学PKU"

@sing1ee
Copy link
Owner

sing1ee commented Sep 6, 2018

@yyhjifeng 没明白,字就是term query,词就是phrase query

@yyhjifeng
Copy link
Author

就是我这边根据readme 到了 http://localhost:9200/jieba_index/fulltext/_search
{
"query" : { "match" : { "content" : "北京大学" }},

这一步, 得到结果和你写的不一致 。我这边 是
"中国的伟《大》时代来临了,欢迎参观《北》《京》《大》《学》PKU"

第一个问题,这个结果好像是按字匹配。不是按词。和你文档写的结果不一致
第二个问题, 同义词好像失效。

我这边是按照你文档一步一步复制粘贴,按理没有问题的呢。why?

@yyhjifeng
Copy link
Author

没有执行mapping 这一步

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants