elasticsearch 7.6.1 常用數據查詢語句


1、創建索引 ( index)

 

curl   -H'Content-Type: application/json' -XPUT http://127.0.0.1:9200/test_index/_doc/1  -d'{
"mappings": {
  "properties": {
    "title": { "type": "text", "analyzer": "ik_smart" }, 
    "description": { "type": "text", "analyzer": "ik_smart" },
    "price": { "type": "scaled_float", "scaling_factor": 100 }
  }
}}'

  

 

2、增加內容

    

curl -H'Content-Type: application/json' -XPUT http://127.0.0.1:9200/test_index/_doc/1?pretty -d'{
    "title": "iPhone X",
    "description": "新品到貨",
    "price": 8848
}'

curl -H'Content-Type: application/json' -XPUT http://127.0.0.1:9200/test_index/_doc/2?pretty -d'{
    "title": "OPPO R15",
    "description": "新品到貨",
    "price": 2000
}'

  

3、查詢記錄

    

curl -XPOST -H'Content-Type:application/json' http://localhost:9200/test_index/_doc/_search?pretty -d'
{
    "query" : { "match" : { "description" : "新" }}
 }'

4、獲得單個記錄

  

curl http://localhost:9200/test_index/_doc/1?pretty

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM