2020-09-22

1.创建索引
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.搜索数据
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
}

你可能感兴趣的:(2020-09-22)