自动mapping带来的问题
插入几条数据
PUT /website/article/1
{
"post_date": "2017-01-01",
"title": "my first article",
"content": "this is my first article in this website",
"author_id": 11400
}
PUT /website/article/2
{
"post_date": "2017-01-02",
"title": "my second article",
"content": "this is my second article in this website",
"author_id": 11400
}
PUT /website/article/3
{
"post_date": "2017-01-03",
"title": "my third article",
"content": "this is my third article in this website",
"author_id": 11400
}查看插入的数据
尝试各种搜索
你会发现第二条指令和第四条指令返回的结果是错误的
来看一下mapping
返回结果:
搜索结果不一致的原因:因为es自动建立mapping的时候,设置了不同的field不同的data type。不同的data type的分词、搜索等行为是不一样的。所以出现了_all field和post_date field的搜索表现完全不一样。
准确值搜索 与全文检索搜索 对比
关键词
准确值搜搜
全文检索搜索
2017-08-08
必须输入与2017-08-08完全相同才可以搜出来
输入2017,或者08,都可以搜索出来;
由此可知全文检索是模糊匹配:
就是说全文索引搜索不单纯的只是匹配完整的一个值,而是可以对值进行拆分词语后(分词)进行匹配,也可以通过缩写、时态、大小写、同义词等进行匹配
Last updated
Was this helpful?