1.創(chuàng)建索引
put http://ip:9200/bos-base-tenant-2020-09-22-log
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"max_ngram_diff": 30
},
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 30
}
},
"analyzer": {
"autocomplete_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"userID": {
"type": "integer"
},
"opname": {
"type": "text",
"analyzer": "autocomplete_analyzer",
"search_analyzer": "standard"
},
"description": {
"type": "text",
"analyzer": "autocomplete_analyzer",
"search_analyzer": "standard"
},
"time": {
"type": "date"
}
}
}
}
}
2.搜索數(shù)據(jù)
post http://ip:9200/bos-base-tenant-2020-09-22-log/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"time": {
"gte": 1600617600,
"lte": "now"
}
}
},
{
"bool": {
"should": [
{
"match_phrase": {
"description": "用戶名或密碼錯誤"
}
},
{
"match_phrase": {
"opname": "流程管理"
}
}
]
}
}
]
}
},
"sort": [],
"from": 0,
"size": 100
}