Elasticsearch URL语法

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

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

返回信息

Elasticsearch URL语法

查看head索引页面

Elasticsearch URL语法

使用脚本创建索引

Elasticsearch URL语法

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}
"

使用方式

Elasticsearch URL语法

查看head页面的索引信息

Elasticsearch URL语法

 

 

 

较全的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"
            }
        }
    }
}