curl -X PUT 'http://127.0.0.1:9200/news_info/news_info/_mapping/' -H 'Content-Type:application/json' -d'
{
"properties": {
"topic": {
"store": true,
"type": "keyword"
},
"language_txt": {
"store": true,
"type": "keyword"
},
"summary": {
"store": true,
"type": "text"
},
"is_dup": {
"store": true,
"type": "integer"
},
"dup_id": {
"store": true,
"type": "keyword"
},
"is_del": {
"store": true,
"type": "integer"
}
}
}'
查看es mapping设置:
curl -XGET 'http://127.0.0.1:9200/news_info/_settings?pretty'
根据条件过滤,在聚合:
curl -XGET 'http://127.0.0.1:9200/news_info/_search?pretty' -H 'Content-Type:application/json' -d'
{
"size":0 ,
"query" : {
"bool" : {
"must" : [
{
"range" : {
"pubtime" : {
"from" : "2021-12-21 00:00:00",
"to" : "2021-12-28 00:00:00",
"include_lower" : true,
"include_upper" : true,
"boost" : 1.0
}
}
},
{
"query_string" : {
"query" : "XXXX YYY",
"default_field" : "site",
"fields" : [ ],
"use_dis_max" : true,
"tie_breaker" : 0.0,
"default_operator" : "or",
"auto_generate_phrase_queries" : false,
"max_determinized_states" : 10000,
"enable_position_increments" : true,
"fuzziness" : "AUTO",
"fuzzy_prefix_length" : 0,
"fuzzy_max_expansions" : 50,
"phrase_slop" : 0,
"escape" : false,
"split_on_whitespace" : true,
"boost" : 1.0
}
}
],
"must_not" : [
{
"term" : {
"is_del" : {
"value" : "1",
"boost" : 1.0
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"aggregations" : {
"agg_topic" : {
"terms" : {
"field" : "topic",
"size" : 15,
"min_doc_count" : 1,
"shard_min_doc_count" : 0,
"show_term_doc_count_error" : false,
"order" : {
"_count" : "desc"
}
}
}
}
}'