ElasticSearch 构建索引与映射

2020-08-25  本文已影响0人  索性流年

参考于蚂蚁课堂

工具

image.png

删除索引

DELETE /goods
image.png

创建索引

PUT /goods
image.png

获取索引

GET /goods
image.png

构建索引映射

POST /goods/_mapping/goods
{
      "goods": {
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "attribute_list": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "category_id": {
            "type": "long"
          },
          "created_time": {
            "type": "date"
          },
          "detail": {
            "type": "text",
             "analyzer":"ik_smart",
            "search_analyzer":"ik_smart"

          },
          "id": {
            "type": "long"
          },
          "main_image": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "name": {
            "type": "text",
            "analyzer":"ik_smart",
            "search_analyzer":"ik_smart"

          },
          "revision": {
            "type": "long"
          },
          "status": {
            "type": "long"
          },
          "sub_images": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "subtitle": {
            "type": "text",
          "analyzer":"ik_smart",
         "search_analyzer":"ik_smart"

          },
          "updated_time": {
            "type": "date"
          }
        }
      }
}
image.png

添加数据

POST /goods/_doc
image.png

查询所有数据

GET /goods/_search
image.png
上一篇 下一篇

猜你喜欢

热点阅读