# 设置 JVM 初始内存为 1G。此值可以设置与-Xmx 相同,以避免每次垃圾回收完成后 JVM 重新分配内存 # Xms represents the initial size of total heap space # 设置 JVM 最大可用内存为 1G # Xmx represents the maximum size of total heap space -Xms1g -Xmx1g
安装postman
{ "shopping"【索引名】: { "aliases"【别名】: {}, "mappings"【映射】: {}, "settings"【设置】: { "index"【设置 - 索引】: { "creation_date"【设置 - 索引 - 创建时间】: "1614265373911", "number_of_shards"【设置 - 索引 - 主分片数量】: "1", "number_of_replicas"【设置 - 索引 - 副分片数量】: "1", "uuid"【设置 - 索引 - 唯一标识】: "eI5wemRERTumxGCc1bAk2A", "version"【设置 - 索引 - 版本】: { "created": "7080099" }, "provided_name"【设置 - 索引 - 名称】: "shopping" } } } }
{ "_index"【索引】: "shopping", "_type"【文档类型】: "_doc", "_id": "1", "_version": 2, "_seq_no": 2, "_primary_term": 2, "found"【查询结果】: true, # true 表示查找到,false 表示未查找到 "_source"【文档源信息】: { "title": "华为手机", "category": "华为", "images": "http://www.gulixueyuan.com/hw.jpg", "price": 4999.00 } }
{ "title":"华为手机", "category":"华为", "images":"http://www.gulixueyuan.com/hw.jpg", "price":4999.00 }
{ "doc": { "price":3000.00 } }
//响应内容 { "_index": "shopping", "_type": "_doc", "_id": "1", "_version"【版本】: 4, #对数据的操作,都会更新版本 "result"【结果】: "deleted", # deleted 表示数据被标记为删除 "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 4, "_primary_term": 2 }
//请求 { "query":{ "match":{ "price":4000.00 } } }
{ "properties": { "name":{ "type": "text", "index": true }, "sex":{ "type": "text", "index": false }, "age":{ "type": "long", "index": false } } }
{ "settings": {}, "mappings": { "properties": { "name":{ "type": "text", "index": true }, "sex":{ "type": "text", "index": false }, "age":{ "type": "long", "index": false } } } } //响应 { "took【查询花费时间,单位毫秒】" : 1116, "timed_out【是否超时】" : false, "_shards【分片信息】" : { "total【总数】" : 1, "successful【成功】" : 1, "skipped【忽略】" : 0, "failed【失败】" : 0 }, "hits【搜索命中结果】" : { "total"【搜索条件匹配的文档总数】: { "value"【总命中计数的值】: 3, "relation"【计数规则】: "eq" # eq 表示计数准确, gte 表示计数不准确 }, "max_score【匹配度分值】" : 1.0, "hits【命中结果集合】" : [ 。。。 } ] } }
// 请求 { "query": { "match": { "name":"zhangsan" } } }
{ "query": { "multi_match": { "query": "zhangsan", "fields": ["name","nickname"] } } }
{ "query": { "term": { "name": { "value": "zhangsan" } } } }
{ "query": { "terms": { "name": ["zhangsan","lisi"] } } }
//请求 { "_source": ["name","nickname"], "query": { "terms": { "nickname": ["zhangsan"] } } }
//请求 { "_source": { "includes": ["name","nickname"] }, "query": { "terms": { "nickname": ["zhangsan"] } } } //请求2 { "_source": { "excludes": ["name","nickname"] }, "query": { "terms": { "nickname": ["zhangsan"] } } }
bool
把各种其它查询通过must
(必须 )、must_not
(必须不)、should
(应该)的方式进行组合 GET http://127.0.0.1:9200/student/_search//请求 { "query": { "bool": { "must": [ { "match": { "name": "zhangsan" } } ], "must_not": [ { "match": { "age": "40" } } ], "should": [ { "match": { "sex": "男" } } ] } } }
{ "query": { "range": { "age": { "gte": 30, "lte": 35 } } } }
编辑距离是将一个术语转换为另一个术语所需的一个字符更改的次数。这些更改可以包括:
更改字符(box → fox)
删除字符(black → lack)
插入字符(sic → sick)
转置字符(act → cat)
{ "query": { "fuzzy": { "title": { "value": "zhangsan" } } } } { "query": { "fuzzy": { "title": { "value": "zhangsan", "fuzziness": 2 } } } }
{ "query": { "match_all": {} }, "sort": [ { "age": { "order": "desc" } }, { "_score":{ "order": "desc" } } ] }
{ "query": { "match": { "name": "zhangsan" } }, "highlight": { "pre_tags": "<font color='red'>", "post_tags": "</font>", "fields": { "name": {} } } }
{ "query": { "match_all": {} }, "sort": [ { "age": { "order": "desc" } } ], "from": 0, "size": 2 }
{ "aggs":{ "stats_age":{ "stats":{"field":"age"} } }, "size":0 }
{ "aggs":{ "age_groupby":{ "terms":{"field":"age"} } }, "size":0 }
{ "aggs":{ "age_groupby":{ "terms":{"field":"age"} } }, "size":0 }