我想搜类似 select * from table where title like "%中国行%" or doc_content like "%中国行%";
下面这句有啥问题吗?查不出内容。
192.168.33.10:9200/test/_search?pretty
{
"query": {
"bool": {
"should": [
{
"term": {
"title": "中国行"
}
},
{
"term": {
"doc_content": "中国行"
}
}
]
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
term是精确匹配,达不到mysql中like的效果,如果你要模糊匹配,应该用match,match会对文本进行分词然后匹配查询:
192.168.33.10:9200/test/_search?pretty
{
}