Elasticsearch URL语法

14 篇文章 0 订阅
2 篇文章 0 订阅

创建简单索引 索引只能小写

         curl -X PUT "localhost:9200/myindex?pretty"

返回信息

查看head索引页面

使用脚本创建索引

es.sh为控制脚本

mapping为请求参数脚本

内容如下:

mapping文件

{
    "product": {
            "properties": {
                "title": {
                    "type": "string",
                    "store": "yes"
                },
                "description": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "price": {
                    "type": "double"
                },
                "onSale": {
                    "type": "boolean"
                },
                "type": {
                    "type": "integer"
                },
                "createDate": {
                    "type": "date"
                }
            }
        }
}

es.sh文件

address=127.0.0.1:9200
index=$1 # 索引名称
mapping=`cat mapping`
#创建索引
curl -X PUT "${address}/${index}"
#设置mapping
curl -XPOST "http://${address}/${index}/product/_mapping?pretty" -d "
${mapping}
"

使用方式

查看head页面的索引信息

 

较全的mapping

{
    "索引名称": {
        "_all": {
            "enabled": false
        },
        "properties": {
            "istat": {
                "analyzer": "standard",
                "type": "text"
            },
            "fileName": {
                "type": "keyword"
            },
            "flag": {
                "analyzer": "standard",
                "type": "text"
            },
            "bc_bockhheight": {
                "type": "keyword"
            },
            "_port_": {
                "type": "keyword"
            },
            "bc_hashvalue": {
                "type": "keyword"
            },
            "_createDate_": {
                "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'+08:00'",
                "type": "date"
            },
            "listener_time": {
                "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'+08:00'",
                "type": "date"
            },
            "quality": {
                "analyzer": "standard",
                "type": "text"
            },
            "@timestamp": {
                "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'+08:00'",
                "type": "date"
            },
            "bc_transactioncode": {
                "type": "keyword"
            },
            "_ip_": {
                "type": "keyword"
            },
            "original_name": {
                "type": "keyword"
            },
            "_sysNo_": {
                "type": "keyword"
            },
            "value": {
                "type": "double"
            },
            "_nodeName_": {
                "type": "keyword"
            }
        }
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小钻风巡山

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值