1.对类型为keyword(原String)的数据不会进行全文检索
2.对类型为 text的数据,创建 mappings时 可选择 standard 分词器或IK分词器,只有选择了IK分词器的,中文才会按照词进行查询。
put:
{
"mappings":
{
"properties":
{
"id":
{
"type":"long",
"store":true
}
,
"title":
{
"type":"text",
"store":true,
"index":true,
"analyzer":"standard"
}
,
"content":
{
"type":"text",
"store":true,
"index":true,
"analyzer":"ik_smart"
}
}
}
}
Post:
{
"id":1,
"title":"曾经的技术",
"content":"曾经的技术"
}
Get:
{
“query”: {
“match”: {
“title”: “经过一年”
}
}
}
能查到数据 ,因为把title拆成了一个一个的字
{
"query": {
"match": {
"content": "经过一年"
}
}
}
查不到: 因为存的是”曾经“”的“”技术“,这三个词,查询条件是 ”经过“”一年“这两个词