美文网首页
实用篇第五天(Elasticsearch, 索引,文档,REST

实用篇第五天(Elasticsearch, 索引,文档,REST

作者: Cook1fan | 来源:发表于2022-01-22 13:58 被阅读0次
image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png
docker run -d \
--name es \
-e "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
-e "discovery.type=single-node" \
-v /home/vagrant/elasticsearch/data:/usr/share/elasticsearch/data \
-v /home/vagrant/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
--privileged \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
elasticsearch:7.16.3
image.png
docker run -d \
--name kibana \
-e ELASTICSEARCH_HOSTS=http://es:9200 \
--network=es-net \
-p 5601:5601 \
kibana:7.16.3
image.png
POST /_analyze
{
  "text": "黑马程序员学习java太棒了",
  "analyzer": "english"
}
image.png image.png image.png image.png
POST /_analyze
{
  "text": "黑马程序员学习java太棒了",
  "analyzer": "ik_max_word"
}

POST /_analyze
{
  "text": "传智教育的课程可以白嫖,而且就业率高达95%,奥利给",
  "analyzer": "ik_smart"
}
image.png image.png image.png image.png image.png image.png image.png image.png image.png
PUT /heima
{
  "mappings": {
    "properties": {
      "info": {
        "type": "text",
        "analyzer": "ik_smart"
      },
      "email": {
        "type": "keyword",
        "index": false
      },
      "name": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "keyword"
          }
        }
      }
    }
  }
}
image.png image.png
GET /heima

PUT /heima/_mapping
{
  "properties": {
    "age": {
      "type": "long"
    }
  }
}

DELETE /heima
image.png image.png image.png
POST /heima/_doc/1
{
  "info": "黑马程序员Java讲师",
  "email": "zy@itcast.cn",
  "name": {
    "firstName": "云",
    "lastName": "赵"
  }
}
image.png
GET /heima/_doc/1

DELETE /heima/_doc/1
image.png
PUT /heima/_doc/1
{
  "info": "黑马程序员Java讲师",
  "email": "zhaoyun@itcast.cn",
  "name": {
    "firstName": "云",
    "lastName": "赵"
  }
}

POST /heima/_update/1
{
  "doc": {
    "email": "ZY@itcast.cn"
  }
}
image.png image.png image.png image.png image.png image.png
PUT /order
{
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "serialNumber": {
        "type": "keyword"
      },
      "customerName": {
        "type": "text", 
        "analyzer": "ik_max_word", 
        "copy_to": "all"
      },
      "receiveName": {
        "type": "text", 
        "analyzer": "ik_max_word",
        "copy_to": "all"
      },
      "receivePhone": {
        "type": "keyword",
        "copy_to": "all"
      },
      "receiveAddress": {
        "type": "keyword",
        "index": false
      },
      "totalAmount": {
        "type": "double"
      },
      "location": {
        "type": "geo_point"
      },
      "all": {
        "type": "text",
        "analyzer": "ik_max_word"
      }
    }
  }
}
image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png image.png 1642847332(1).png

相关文章

网友评论

      本文标题:实用篇第五天(Elasticsearch, 索引,文档,REST

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