ElasticSearch 笔记

简单搭建

docker pull elastcisearch:7.3.0

docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.3.0

image.png

image.png

基本命令

安装分词器

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip

kibana创建一个索引

PUT /city
{
    "settings":{
        "index":{
            "number_of_shards":3,
            "number_of_replicas":0
        }
    },
   "city_name":{
    "article":{
      "properties":{
        "id":{
          "type":"long"
        },
        "name":{
          "type":"text",
          "analyzer": "ik_max_word"
        }
      }
    }
  }
}

为索引添加一条数据

POST /city/city_name/_search
{
  "id":1,
  "name":"杭州"
}

查询索引数据

POST /city/_search
{
  "query": { "match": { "name": "苏州" } }
}

获取索引结构

GET city/_mappings

你可能感兴趣的:(ElasticSearch 笔记)