美文网首页
ElasticSearch学习

ElasticSearch学习

作者: 安以北往南 | 来源:发表于2019-04-25 15:18 被阅读0次
PUT /ecommerce/product/1
{
    "name" : "gaolujie yagao",
    "desc" :  "gaoxiao meibai",
    "price" :  30,
    "producer" :      "gaolujie producer",
    "tags": [ "meibai", "fangzhu" ]
}
PUT /ecommerce/product/2
{
    "name" : "jiajieshi yagao",
    "desc" :  "youxiao fangzhu",
    "price" :  25,
    "producer" :      "jiajieshi producer",
    "tags": [ "fangzhu" ]
}
PUT /ecommerce/product/3
{
    "name" : "zhonghua yagao",
    "desc" :  "caoben zhiwu",
    "price" :  40,
    "producer" :      "zhonghua producer",
    "tags": [ "qingxin" ]
}

GET jason/well/1

PUT jason/well/1
{
  "age": 25,
    "name": "jason",
    "desc": "is a good man handsome boy 222",
    "body":{
      "height": 173,
      "weight": "65kg"
    }
}

POST jason/well
{
  "age": 20,
    "name": "jason",
    "desc": "is a good man handsome boy 222",
    "body":{
      "height": 173,
      "weight": "65kg"
    }
}

GET  /ecommerce/product/1

PUT /ecommerce/product/ZXKwUmoBbmHfsIVvdvnx
{
    "name" : "jiaqiangban gaolujie yagao",
    "desc" :  "gaoxiao meibai",
    "price" :  32,
    "producer" :      "gaolujie producer",
    "tags": [ "meibai", "fangzhu" ]
}

PUT jason/well/a3KwUmoBbmHfsIVvfPl1
{
  "age": 35,
    "name": "jason",
    "desc": "is a good man handsome boy 222",
    "body":{
      "height": 173,
      "weight": "65kg"
    }
}

POST jason/well/a3KwUmoBbmHfsIVvfPl1/_update
{
  "doc": {
    "name": "jasonandy",
    "age": 35
  }
}

GET jason/well/a3KwUmoBbmHfsIVvfPl1

DELETE jason/well/a3KwUmoBbmHfsIVvfPl1

GET jason/well/_search?q=name:jason&sort=age:asc


GET /jason/well/_search
{
  "query": { "match_all": {} }
}

GET /ecommerce/product/_search
{
  "query": { "match_all": {} }
}

GET /ecommerce/product/_search
{
  "query": { "match": {
    "name": "yagao"
  } 
  },
  "sort": [
    {
      "price": {
        "order": "asc"
      }
    }
  ]
}

GET /ecommerce/product/_search
{
  "query":{
    "match_all": {}
  },
  "from": 0,
  "size": 2
}

GET ecommerce/product/_search
{
    "query": {
        "bool": {
            "filter": {
                "range": {
                    "price": {
                        "gte": 25
                    }
                }
            },
            "must": {
                "match": {
                    "name": "yagao"
                }
            }
        }
    }
}

GET ecommerce/product/_search
{
    "query": {
        "bool": {
            "filter": {
                "range": {
                    "price": {
                        "gte": 25
                    }
                }
            },
            "must": {
                "match": {
                    "name": "yagao"
                }
            }
        }
    }
}

GET /jason/well/_search

GET jason/well/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "jason"
          }
        }
      ],
      "filter": {
        "range": {
          "age": {
            "gte": 25,
            "lte": 30
          }
        }
      }
    }
  }
}


GET jason/well/_search
{
  "query": {
    "match": {
      "desc": "boy handsom"
    }
  }
}

GET jason/well/_search
{
  "query": {
    "match": {
      "desc": "bo"
    }
  }
}

GET jason/well/_search
{
  "query": {
    "match_phrase": {
      "desc": "boy 222"
    }
  }
}


GET jason/well/_search
{
  "query": {
    "bool": {
      "must": [
        {"match": {
          "desc": "boy"
        }}
      ],
      "should": [
        {"match": {
          "name": "jason"
        }}
      ],
      "must_not": [
        {"match": {
          "age": "25"
        }}
      ]
    }
  }
}



GET  ecommerce/product/_search
{
  "size": 0, 
  "aggs": {
    "agg_by_name": {
      "terms": {
        "field": "tags"
      }
    }
  }
  
  
}

PUT ecommerce/_mapping/product
{
  "properties": {
    "tags":{
      "type": "text",
      "fielddata": true
    }
  }
}

GET ecommerce/product/_search
{
  "query": {
    "match": {
      "name": "yagao"
    }
  },
  "aggs": {
    "agg_by_name": {
      "terms": {
        "field": "tags",
        "size": 10
      }
    }
  }
  
}


GET ecommerce/product/_search
{
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags",
        "size": 10
      },
      "aggs": {
        "avg_price": {
          "avg": {
            "field": "price"
          }
        }
      }
    }
  }
  
}


PUT my_index/my_type/1
{ 
  "region": "US",
  "manager": { 
    "age":     30,
    "name": { 
      "first": "John",
      "last":  "Smith"
    }
  }
}

GET _cat/indices?v



GET _search


PUT andy
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, 
            "number_of_replicas" : 2 
        }
    }
}

PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

DELETE andy
DELETE wubin
DELETE order
DELETE name
DELETE  _cluster/settings
DELETE user
DELETE  my_index
DELETE hbi-elasticsearch
DELETE myindex
DELETE 1
DELETE jason

PUT jason
{
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 2
  },
  "mappings": {
    "type1":{
      "properties": {
        "filed1":{"type": "text"}
      }
    }
  }
}

GET jason

POST jason/_settings,_mappings

HEAD jason

POST jason/_close

GET jason

GET jason/

POST jason/_open

PUT jason/type1/1
{ 
  "region": "US",
  "manager": { 
    "age":     30,
    "name": { 
      "first": "John",
      "last":  "Smith"
    }
  }
}

PUT jason/type1/1
{
  "mappings": {
    "tweet": {
      "properties": {
        "message": {
          "type": "text"
        }
      }
    }
  }
}

PUT jason/_mapping/type1
{
  "properties": {
    "name": {
      "type": "text"
    }
  }
}


GET jason/_mapping


GET /_all/_mapping


PUT publications
{
    "mappings": {
        "article": {
            "properties": {
                "id": { "type": "text" },
                "title":  { "type": "text"},
                "abstract": { "type": "text"},
                "author": {
                    "properties": {
                        "id": { "type": "text" },
                        "name": { "type": "text" }
                    }
                }
            }
        }
    }
}


GET publications/_mapping/article/field/author.name

GET publications/_mapping/article/field/title
GET publications/_mapping/article/field/id
GET publications/_mapping/article/field/author.id

HEAD jason/_mapping/type1

GET _aliases

POST /_aliases
{
    "actions" : [
        { "add" : { "publications" : "publications_alias" } }
    ]
}


GET jason/_settings

PUT jason/_settings
{
    "index" : {
        "number_of_replicas" : 2
    }
}

PUT ecommerce/_settings
{
  "index" :{
    "number_of_replicas" :0
  }
}

PUT jason/_settings
{
    "index" : {
        "refresh_interval" : "-1"
    }
}

PUT jason/_settings
{
    "index" : {
        "refresh_interval" : "1s"
    }
}

GET _analyze
{
  "analyzer": "standard",
  "text": [
  
  "this is a nice day , so time you can you it ,just do it with me."
    ]
}


GET _analyze
{
  "analyzer" : "chinese",
  "text" : "我宣布中华人民共和国成立了 - 吴斌"
}

GET _analyze
{
  "analyzer" : "ik_smart",
  "text" : "我宣布中华人民共和国成立了 - 吴斌"
}



GET _analyze
{
  "analyzer" : "ik_max_word",
  "text" : "我宣布中华人民共和国成立了 - 吴斌"
}


PUT _template/template_1
{
  "template": "temp_late",
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "type1": {
      "_source": {
        "enabled": false
      },
      "properties": {
        "host_name": {
          "type": "keyword"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z YYYY"
        }
      }
    }
  }
}

GET _template


DELETE /_template/template_1

GET /_template

GET /_stats

GET jason/_segments

POST /jason/_cache/clear

POST /ecommerce/_cache/clear

POST publications/_cache/clear


[csdn参考](https://blog.csdn.net/napoay/article/details/73251965)

索引

ik

相关文章

网友评论

      本文标题:ElasticSearch学习

      本文链接:https://www.haomeiwen.com/subject/olrzgqtx.html