创建索引
{
"settings": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "standard",
"filter": [
"lowercase",
"stemmer",
"bot_filter_synonym"
]
}
},
"filter": {
"filter_synonym": {
"type": "synonym",
"format" : "wordnet",
"synonyms_path": "elastic-synonyms.json",
"ignore_case": true
}
}
},
"index": {
"number_of_shards": "3",
"number_of_replicas": "3"
}
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"id": {
"type": "text",
"analyzer": "synonym",
"search_analyzer": "synonym"
},
"botid": {
"type": "text",
"analyzer": "synonym",
"search_analyzer": "synonym"
},
"qid": {
"type": "text",
"analyzer": "synonym",
"search_analyzer": "synonym"
},
"msg": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "synonym",
"search_analyzer": "synonym"
},
"raw_msg": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "synonym",
"search_analyzer": "synonym"
},
"start_time": {
"type": "date"
},
"end_time": {
"type": "date"
},
"enable_forever": {
"type": "long"
}
}
}
}
多条件查询
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"match_phrase": {
"botid": {
"query": "124"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase": {
"msg": {
"query": "cs4"
}
}
},
{
"match_phrase": {
"raw_msg": {
"query": "测试3"
}
}
}
]
}
}
]
}
},
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase": {
"enable_forever": {
"query": "1"
}
}
},
{
"bool": {
"must": [
{
"range": {
"start_time": {
"gte": 1659951914000
}
}
},
{
"range": {
"end_time": {
"lte": 1659951919000
}
}
}
]
}
}
]
}
}
]
}
}
]
}
}
}