es语法


GET _cat/indices #查看所有表 参考链接:     对个字段都要求和? 字段值去重统计与显示ok 空数组的记录 must、should混合使用   ----------数据类型-------------------------------------------------------------------------------- 参考链接:https://blog.csdn.net/gongpulin/article/details/78570246   ------------------------------------------------------------------------------------------ 参考链接:https://blog.csdn.net/taoshujian/article/details/55669976   GET查、PUT增/改、POST增 和 DELETE删 POST不用加具体的id,它是作用在一个集合资源之上的,而PUT操作是作用在一个具体资源之上的   POST /website/blog/1/_update {    "doc" : {       "aa" :"bbb",       "123": 0    } } #更新部分documents,仅更新aa字段和123字段,不会整个文档更新     PUT /customer/external/1?pretty {   "name": "John Doe" } #必须有参数文档id无则报错,id不存在会自动创建存在则覆盖(注意:PUT会将新的json值完全替换掉旧的,整个文档覆盖)     POST /customer/external?pretty {   "name": "Jane Doe" }   #不指定id创建时document需要使用POST命令,会自动生成id 如:AVpQdsOSxaunvQAUZY5w     DELETE /customer/external/1?pretty   #删除documents ------------------------------------------------------------------------------------------   mysql数据库database相当于 es索引index mysql表table       相当于 es类型type mysql数据行row     相当于 es文档document mysql数据列column  相当于 es字段field   bool 实现复合查询 sort排序 "from" : 0,  "size" : 200 控制指定数量 _source 返回指定字段 "sort": 允许我们将检索的结果以指定的字段进行排序显示   match_all    查询所有 match        模糊匹配,将被查询值进行分词 match_phrase 完全匹配,查询指定段落 term         查询时判断某个document是否包含某个具体的值,不会对被查询的值进行分词查询 range        作区间搜索(日期区间或数值区间)          gte:  大于或等于          gt:   大于          lte:  小于或等于          lt:     小于          boost:  设置查询的提升值,默认为1.0   "cardinality": 字段值去重统计 "collapse": 返回去重内容     GET /national_credit_company_analysis/company_analysis/_mapping #查看字段类型   GET /national_credit_company_news_list/_search {   "query": {     "match": {       "field_id": "03"     }   },   "sort": [     {       "published": {         "order": "desc"       }     }   ] } #排序 GET /national_credit_company_news_list/_search {   "query": {     "match_all": {     }   } } #match_all 查询全部 GET /national_credit_event_news_list/_search {   "query": {     "bool": {       "must_not": {          "match_phrase": {           "subject_involved_id": """"[]"""         }       }     }   } } GET /national_credit_subject_news_analysis/_search {   "query": {     "match_phrase": {       "task_id": "86"     }   },   "aggs": {     "a2": {       "sum": {         "field": "negative_num"       }     }   } } #sum 求和 、min 最小值 、max最大值、avg平均值 GET /national_credit_subject_news_list/_search {   "query": {     "terms": {       "task_id": [         "86",         "87"       ]     }   } } #值or GET /national_credit_subject_news_list/_search {   "query": {     "bool": {       "must": [         {"term":{ "task_id": "86"}},         {"term":{ "title": "新零售 从概念走向现实"}}                  ]     }   } } GET /national_credit_subject_news_list/_search {   "query": {     "bool": {       "must": [         {"match_phrase":{ "body": "信用服务机构"}}         ],         "must_not": [           {"match_phrase":{ "title": "信用服务机构"}}         ]     }   } } GET /national_credit_subject_news_list/_search {   "query": {     "bool": {       "should": [         {"match_phrase":{ "body": "信用服务机构"}},         {"match_phrase":{ "title": "信用服务机构"}}                  ]     }   } } GET /national_credit_hot_news_list/_search {"query":{"bool":{   "must":[     {"match_phrase":{"status":"0"}},     {"bool":{       "should":[         {"match_phrase":{"body":"信用服务机构"}},         {"match_phrase":{"title":"信用服务机构"}}         ]}}]}}} #must和should混合 #must :多个查询条件的完{}全匹配,相当于 and #must_not :多个查询条件的相反匹配,相当于 not #should :至少有一个查询条件匹配, 相当于 or GET /national_credit_evaluation_news_list/_search {   "_source": ["enterprise_name","status"],   "query": {     "term": {       "status":  "0"     }   } } #_source 返回指定字段 GET /national_credit_evaluation_news_list/_search {   "size": 0,   "query": {     "match_phrase": {       "status":"0"     }   },   "aggs": {     "distinct": {       "cardinality": {"field" :"enterprise_name.keyword"}            }   } } #统计某个字段值去重后数量 GET /national_credit_evaluation_news_list/_search {   "from" : 0, "size" : 100,   "_source": "",   "query": {     "match_phrase": {       "status": "0"     }   },   "collapse": {"field" :"enterprise_name.keyword"} } #返回去重内容 GET /national_credit_subject_news_analysis/_search {   "size": 1,   "query": {     "bool": {       "must": [         {"match_phrase": {           "task_id": "96"         }},         {"range": {           "date": {             "gte": "2018-01-28",             "lte": "2018-01-28"           }         }}       ]     }   },   "aggs": {     "negative_num": {       "sum": {"field": "negative_num"}     }   } } #---某个专题某个时间段统计信息 GET /national_credit_all_news/_search {   "query": {     "range": {       "update_time": {         "gte": "2019-01-28 00:00:00",         "lte": "2019-01-27 23:59:59"         }     }   } } #range 时间范围 ################################################ PUT /national_credit_company_news_list/_settings {     "max_result_window" : 100000000 }  
es