es如何像sql那样使用like查询,即要查询包含某个词,但搜索只是这个词的一部分
先删除my_index,再初始化mapping:
{
"mappings": {
"address": {
"properties": {
"postcode": {
"type": "keyword"
}
}
}
}
}
索引一些文档:
PUT /my_index/address/1
{ "postcode": "W1V 3DG" }
PUT /my_index/address/2
{ "postcode": "W2F 8HW" }
PUT /my_index/address/3
{ "postcode": "W1F 7HW" }
PUT /my_index/address/4
{ "postcode": "WC1N 1LZ" }
PUT /my_index/address/5
{ "postcode": "SW5 0BE" }
prefix 前缀查询
查询关键词不需要是完整的:
prefix是如何查询的呢?倒排索