‘‘‘
GET _search
{
"query": {
"match_all": {}
}
}
GET s18/doc/1
DELETE s18
PUT s18/doc/1
{
"name":"ZYB",
"age":20,
"gender":"男",
"tags":"正人君子",
"b":"19941201"
}
PUT s18/doc/2
{
"name":"yuanyuan",
"age":18,
"gender":"女",
"tags":"活泼大方",
"b":"19900901"
}
PUT s18/doc/3
{
"name":"baobao",
"age":6,
"gender":"女",
"tags":"小孩子",
"b":"19970101"
}
PUT s18/doc/4
{
"name":"long",
"age":22,
"gender":"男",
"tags":"弟弟",
"b":"19930205"
}
PUT s18/doc/5
{
"name":"zhu",
"age":23,
"gender":"男",
"tags":"浪",
"b":"19980501"
}
GET s18/doc/2
GET s18/doc/_search?q=age:23
POST s18/doc/5/_update
{
"doc":{
"tag":"帅气"
}
}
GET s18/doc/_search
{
"query":{
"match":{
"age":18
}
}
}
GET s18/doc/_search
{
"query":{
"match":{
"tags":"浪 弟弟"
}
}
}
GET s18/doc/_search
GET s18/doc/_search
{
"query":{
"match_all":{}
}
}
GET s18/doc/_search
{
"query":{
"match_all":{}
},
"sort": [
{
"age": {
"order": "desc"
}
}
]
}
GET s18/doc/_search
{
"query":{
"match_all":{}
},
"sort": [
{
"age": {
"order": "asc"
}
}
]
}
GET s18/doc/_search
{
"query":{
"match_all":{}
},
"sort": [
{
"age": {
"order": "desc"
}
}
]
}
GET s18/doc/_search
{
"query":{
"match_all":{}
},
"from":0,
"size":2
}
GET s18/doc/_search
{
"query":{
"bool": {
"should": [
{
"match":{
"name":"zhu"
}
},
{
"match": {
"age": 18
}
}
]
}
}
}
GET s18/doc/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"gender": "男"
}
},
{
"match": {
"age": "23"
}
}
]
}
}
}
GET s18/doc/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"gender": "男"
}
}
],
"filter": {
"range": {
"age": {
"gt": 20
}
}
}
}
}
}
GET s18/doc/_search
{
"query":{
"match": {
"name": "long"
}
},
"highlight": {
"fields": {
"name":{}
}
}
}
GET s18/doc/_search
{
"query":{
"match": {
"name": "yuanyuan"
}
},
"highlight": {
"pre_tags": "",
"post_tags": "",
"fields": {
"name":{}
}
}
}
GET s18/doc/_search
{
"query": {
"match": {
"name": "yuanyuan"
}
},
"_source":["name","age"]
}
GET s18/doc/_search
{
"query": {
"match": {
"gender": "男"
}
},
"aggs": {
"my_sum": {
"sum": {
"field": "age"
}
}
}
}
GET s18/doc/_search
{
"query": {
"match": {
"gender": "男"
}
},
"aggs": {
"my_max": {
"max": {
"field": "age"
}
}
}
}
GET s18/doc/_search
{
"aggs": {
"my_min": {
"min": {
"field": "age"
}
}
}
}
GET s18/doc/_search
{
"aggs": {
"my_avg": {
"avg": {
"field": "age"
}
}
}
}
GET s18/doc/_search
{
"query": {
"match": {
"gender": "男"
}
},
"aggs": {
"my_group": {
"range": {
"field": "age",
"ranges": [
{
"from": 0,
"to": 10
},
{
"from": 10,
"to":20
},{
"from": 20,
"to":30
}
]
}
}
}
}
GET s18/doc/_search
{
"query": {
"match": {
"gender": "男"
}
},
"aggs": {
"group": {
"range": {
"field": "age",
"ranges": [
{
"from": 0,
"to": 10
},
{
"from": 10,
"to":20
},
{
"from":20,
"to":30
}
]
},
"aggs": {
"my_sum": {
"sum": {
"field": "age"
}
}
}
}
}
}
PUT s2
{
"mappings": {
"doc":{
"properties":{
"name":{
"type":"text"
},
"age":{
"type":"long"
},
"desc":{
"type":"text"
}
}
}
}
}
PUT s2/doc/1
{
"name":"zhang",
"age":21,
"desc":"低调"
}
GET s2/doc/_search
GET s18/_mapping
GET s2/_mapping
PUT s4
{
"mappings": {
"doc":{
"dynamic":true,
"properties":{
"name":{
"type":"text"
}
}
}
}
}
PUT s5
{
"mappings": {
"doc":{
"dynamic":false,
"properties":{
"name":{
"type":"text"
}
}
}
}
}
PUT s7
{
"mappings": {
"doc":{
"properties":{
"title":{
"type":"keyword",
"ignore_above":10
}
}
}
}
}
PUT s7/doc/1
{
"title":"阿达大方阿达大就说了句就方阿达大方"
}
PUT s7/doc/2
{
"title":"123456"
}
PUT s7/doc/3
{
"title":"1234567"
}
GET s7/doc/_search
{
"query": {
"match": {
"title": "1234567"
}
}
}
GET s7/doc/_search
{
"query": {
"match": {
"title": "阿达大方阿达大就说了句就方阿达大方"
}
}
}
GET s7/_mapping
PUT s8
{
"mappings": {
"doc":{
"properties":{
"t1":{
"type":"text",
"index":true
},
"t2":{
"type":"text",
"index":false
}
}
}
}
}
PUT s8/doc/1
{
"t1":"论文的书写方法",
"t2":"论技术安吉技术"
}
GET s8/doc/_search
{
"query": {
"match": {
"t1": "论文"
}
}
}
GET s8/doc/_search
{
"query": {
"match": {
"t2": "论文"
}
}
}
PUT s9
{
"mappings": {
"doc":{
"properties":{
"t1":{
"type":"text",
"copy_to":"full_name"
},
"t2":{
"type":"text",
"copy_to":"full_name"
},
"full_name":{
"type":"text"
}
}
}
}
}
PUT s9/doc/1
{
"t1":"xxx",
"t2":"ooo"
}
GET s9/doc/_search
{
"query": {
"match": {
"t1": "xxx"
}
}
}
GET s9/doc/_search
{
"query": {
"match": {
"full_name": "ooo"
}
}
}
PUT s10
{
"mappings": {
"doc":{
"properties":{
"t1":{
"type":"text",
"copy_to":["f1","f2"]
},
"t2":{
"type":"text",
"copy_to":["f1","f2"]
},
"f1":{
"type":"text"
},
"f2":{
"type":"keyword"
}
}
}
}
}
PUT w1
{
"mappings": {
"doc":{
"properties":{
"name":{
"type":"text"
},
"age":{
"type":"long"
},
"info":{
"properties":{
"addr":{
"type":"text"
},
"tel":{
"type":"long"
}
}
}
}
}
}
}
PUT w1/doc/1
{
"name":"tom",
"age":18,
"info":{
"addr":"北京",
"tel":"010"
}
}
GET w1/doc/_search
{
"query": {
"match": {
"name": "tom"
}
}
}
GET w1/doc/_search
{
"query": {
"match": {
"info.tel": "010"
}
}
}
GET w1
PUT w2
{
"settings": {
"mappings":{
"doc":{
"properties":{
"title":{
"type":"text"
}
}
}
},
"number_of_shards": 3,
"number_of_replicas": 2
}
}
GET s3/_mapping
PUT s3
{
"mappings" : {
"doc" : {
"properties" : {
"age" : {
"type" : "long"
},
"b" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"gender" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"tags" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
GET _analyze
{
"analyzer": "standard",
"text":"中国"
}
PUT t1/doc/1
{
"title":"中国是世界上人口最多的国家"
}
PUT t1/doc/2
{
"title":"美国是世界上军事实力最强大的国家"
}
PUT t1/doc/3
{
"title":"北京是中国的首都"
}
GET t1/doc/_search
{
"query": {
"match": {
"title": "中国"
}
}
}
GET t1/doc/_search
{
"query": {
"match_phrase": {
"title": "中国"
}
}
}
GET t1/doc/_search
{
"query": {
"match_phrase": {
"title": {
"query": "中国世界",
"slop":1
}
}
}
}
PUT t2/doc/1
{
"title":"beautiful girl"
}
PUT t2/doc/2
{
"title":"beautiful so"
}
GET t2/doc/_search
{
"query": {
"match_phrase_prefix": {
"title": "bea"
}
}
}
PUT t3/doc/1
{
"t1":"beautiful girl",
"t2":"beautiful so"
}
GET t3/doc/_search
{
"query": {
"multi_match": {
"query": "beautiful",
"fields": ["t1","t2"]
}
}
}
GET t3/doc/_search
{
"query": {
"multi_match": {
"query": "beautiful",
"fields": ["t1","t2"],
"type":"phrase"
}
}
}
GET t3/doc/_search
{
"query": {
"multi_match": {
"query": "beautiful",
"fields": ["t1","t2"],
"type":"phrase_prefix"
}
}
}
POST _analyze
{
"tokenizer": "path_hierarchy",
"text":"/usr/local/python/python2.7"
}
POST _analyze
{
"tokenizer": "uax_url_email",
"text":"作者:zyb:位置原文:https://www.baidu.com/articles/123.html邮箱:zybyekai@icloud.com版权声明:我的东东"
}
GET _analyze
{
"analyzer": "standard",
"text":"上海自来水来自海上"
}
GET _analyze
{
"analyzer": "ik_smart",
"text":"上海自来水来自海上"
}
GET _analyze
{
"analyzer": "ik_max_word",
"text":"上海自来水来自海上"
}
‘‘‘
原文:https://www.cnblogs.com/zybyekai/p/14403737.html