使用match做全文檢索,比較適合text類型,index=true
GET my_index/my_type/_search
{
"query": {
"match": {
"full_text": "xx yy"
}
}
}
term做詞條查詢,比較適合keyword類型,index=true
POST /_search -d
{
"from":10,
"size":5,
"query":{
"term":{
"eventname":"xx"
}
}
}
POST /_search -d
{
"from":10,
"size":5,
"query":{
"terms":{
"eventname":["xx","yy"]
}
}
}
{
"range" : {
"age" : {
"gte" : 1,
"lte" : 3,
"boost" : 2.0
}
}
}
gte:大於或等於(Greater-than or equal to)
gt:大於(Greater-than)
lte:小於或等於(Less-than or equal to)
lt:小於(Less-than)
ElasticSearch 5.0以後,string類型有重大變更,移除了string
類型,string
字段被拆分成兩種新的數據類型: text
用於全文搜索的,而keyword
用於關鍵詞搜索。
Text:會分詞,然後進行索引
支持模糊、精確查詢
不支持聚合
keyword:不進行分詞,直接索引
支持模糊、精確查詢
支持聚合
FR:徐海濤(hunk Xu)
QQ技術交流羣:386476712