elasticsearch匹配查询不出结果
1、elasticsearch匹配查询不出结果
2、
public function elasticsearch(){ $keyword = $_POST["keyword"]; $elasticsearch = new \Think\ElasticsearchService ('120.27.130.110','9200','my_tmgc','menu'); $searchParams = array( 'query' => array( 'match' => array( 'article_content' => $keyword, ) ), ); $result= $elasticsearch->search( $searchParams ); var_dump($result); }
3、结果:
在输入框输入“1222”,结果是:
string '{"took":5,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}' (length=122)
4、elasticsearch的数据
{ "took": 4, "timed_out": false, "_shards": {
"total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 2, "max_score": 1, "hits": [ { "_index": "my_tmgc", "_type": "menu", "_id": "$z", "_score": 1, "_source": { "article_id": "111", "article_title": "2222", "article_content": "22222222222222222222222222222", "article_cteatetime": "2017-05-04 10:02:05" } }, { "_index": "my_tmgc", "_type": "menu", "_id": "AVvRM9nn77sSD8cdbBLz", "_score": 1, "_source": { "article_id": "113", "article_title": "122222", "article_content": "1222222222222222222222222222222", "article_cteatetime": "2017-05-04 10:04:48" } } ] } }
4、尝试输入article_content字段的完整内容
"1222222222222222222222222222222"
,可以找到结果,但是输入部分内容”1222“
,就是上面的结果,找不到。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我和你遇到的问题一样,请问你有解决办法了吗?