美文网首页
ElasticSearch 构建索引与映射

ElasticSearch 构建索引与映射

作者: 索性流年 | 来源:发表于2020-08-25 16:40 被阅读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

相关文章

网友评论

      本文标题:ElasticSearch 构建索引与映射

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