• es创建索引的格式,并初始化数据


    es创建索引的格式,并初始化数据

    学习了:https://www.imooc.com/video/15759

    1, 创建格式
    POST 127.0.0.1:9200/book/novel/_mappings
    {
        "novel":{
            "properties": {
                "word_count": {
                    "type": "integer"
                },
                "author": {
                    "type": "keyword"
                },
                "title": {
                    "type": "text"
                },
                "publish_date": {
                    "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
                    "type": "date"
                }
            }
        }
    }
    2,插入数据
    PUT 方法进行数据插入,插入同时指定id
    127.0.0.1:9200/book/novel/5
    {
        "author": "王五",
        "title": "菜谱",
        "word_count": 5000,
        "publish_date": "2002-10-01"
    }
    127.0.0.1:9200/book/novel/2
    {
        "author": "李三",
        "title": "Java入门",
        "word_count": 2000,
        "publish_date": "2010-10-01"
    }
    127.0.0.1:9200/book/novel/8
    {
        "author": "瓦力",
        "title": "ElasticSearch入门",
        "word_count": 3000,
        "publish_date": "2017-08-20"
    }
    127.0.0.1:9200/book/novel/9
    {
        "author": "很胖的瓦力",
        "title": "ElasticSearch精通",
        "word_count": 3000,
        "publish_date": "2017-08-15"
    }
    127.0.0.1:9200/book/novel/10
    {
        "author": "牛魔王",
        "title": "芭蕉扇",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/2
    {
        "author": "李三",
        "title": "Java入门",
        "word_count": 2000,
        "publish_date": "2010-10-01"
    }
    127.0.0.1:9200/book/novel/4
    {
        "author": "李四",
        "title": "ElasticSearch大法好",
        "word_count": 1000,
        "publish_date": "2017-08-01"
    }
    127.0.0.1:9200/book/novel/6
    {
        "author": "赵六",
        "title": "剑谱",
        "word_count": 10000,
        "publish_date": "1997-01-01"
    }
    127.0.0.1:9200/book/novel/1
    {
        "author": "张三",
        "title": "移魂大法",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/7
    {
        "author": "张三丰",
        "title": "太极拳",
        "word_count": 1000,
        "publish_date": "1997-01-01"
    }
    127.0.0.1:9200/book/novel/3
    {
        "author": "张四",
        "title": "python入门",
        "word_count": 2000,
        "publish_date": "2005-10-01"
    }
    127.0.0.1:9200/book/novel/11
    {
        "author": "孙悟空",
        "title": "七十二变",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/12
    {
        "author": "瓦力",
        "title": "瓦力教我们学ElasticSearch",
        "word_count": 1000,
        "publish_date": "2017-08-01"
    }
    1, 创建格式
    POST 127.0.0.1:9200/book/novel/_mappings
    {
        "novel":{
            "properties": {
                "word_count": {
                    "type": "integer"
                },
                "author": {
                    "type": "keyword"
                },
                "title": {
                    "type": "text"
                },
                "publish_date": {
                    "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
                    "type": "date"
                }
            }
        }
    }
    2,插入数据
    PUT 方法进行数据插入,插入同时指定id
    127.0.0.1:9200/book/novel/5
    {
        "author": "王五",
        "title": "菜谱",
        "word_count": 5000,
        "publish_date": "2002-10-01"
    }
    127.0.0.1:9200/book/novel/2
    {
        "author": "李三",
        "title": "Java入门",
        "word_count": 2000,
        "publish_date": "2010-10-01"
    }
    127.0.0.1:9200/book/novel/8
    {
        "author": "瓦力",
        "title": "ElasticSearch入门",
        "word_count": 3000,
        "publish_date": "2017-08-20"
    }
    127.0.0.1:9200/book/novel/9
    {
        "author": "很胖的瓦力",
        "title": "ElasticSearch精通",
        "word_count": 3000,
        "publish_date": "2017-08-15"
    }
    127.0.0.1:9200/book/novel/10
    {
        "author": "牛魔王",
        "title": "芭蕉扇",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/2
    {
        "author": "李三",
        "title": "Java入门",
        "word_count": 2000,
        "publish_date": "2010-10-01"
    }
    127.0.0.1:9200/book/novel/4
    {
        "author": "李四",
        "title": "ElasticSearch大法好",
        "word_count": 1000,
        "publish_date": "2017-08-01"
    }
    127.0.0.1:9200/book/novel/6
    {
        "author": "赵六",
        "title": "剑谱",
        "word_count": 10000,
        "publish_date": "1997-01-01"
    }
    127.0.0.1:9200/book/novel/1
    {
        "author": "张三",
        "title": "移魂大法",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/7
    {
        "author": "张三丰",
        "title": "太极拳",
        "word_count": 1000,
        "publish_date": "1997-01-01"
    }
    127.0.0.1:9200/book/novel/3
    {
        "author": "张四",
        "title": "python入门",
        "word_count": 2000,
        "publish_date": "2005-10-01"
    }
    127.0.0.1:9200/book/novel/11
    {
        "author": "孙悟空",
        "title": "七十二变",
        "word_count": 1000,
        "publish_date": "2000-10-01"
    }
    127.0.0.1:9200/book/novel/12
    {
        "author": "瓦力",
        "title": "瓦力教我们学ElasticSearch",
        "word_count": 1000,
        "publish_date": "2017-08-01"
    }
  • 相关阅读:
    windows利用net use删除smb连接
    用jquery的ajax功能获取网站alexa的方法
    11对于Web开发人员和设计师非常有用的在线工具
    Php获取Alexa排行统计
    php获取alexa世界排名值的函数
    26个免费矢量图片免费下载
    对makefile中双冒号规则的学习
    对makefile中 $*的理解
    GNU make manual 翻译(七十三)
    对makefile 中的 静态模式规则的理解
  • 原文地址:https://www.cnblogs.com/stono/p/9060363.html
Copyright © 2020-2023  润新知