Elasticsearch
1.基本使用
#pretty 是为了友好显示输出的数据格式
curl -XPUT http://localhost:9200/test_index?pretty
#查看索引
curl http://localhost:9200/test_index?pretty
- 创建类型
对应的接口地址是 /{index_name}/_mapping/{type_name}
curl -H'Content-Type: application/json' -XPUT http://localhost:9200/test_index/_mapping/_doc?pretty -d'{
"properties": {
"title": { "type": "text", "analyzer": "ik_smart" },
"description": { "type": "text", "analyzer": "ik_smart" },
"price": { "type": "scaled_float", "scaling_factor": 100 }
}
}'
curl -H'Content-Type: application/json' -XPUT http://localhost:9200/test_index/_doc/1?pretty -d'{
"title": "iPhone 8",
"description": "新品到货",
"price": 8848
}'
curl http://localhost:9200/test_index/_doc/1?pretty
curl -XPOST -H'Content-Type:application/json' http://localhost:9200/test_index/_doc/_search?pretty -d'
{
"query" : { "match" : { "description" : "新品" }}
}'