elasticsearch

2019-02-21  本文已影响0人  phpdi

Elasticsearch

1.基本使用

#pretty 是为了友好显示输出的数据格式
curl -XPUT http://localhost:9200/test_index?pretty
#查看索引 
curl http://localhost:9200/test_index?pretty
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" : "新品" }}
}'
上一篇 下一篇

猜你喜欢

热点阅读