current position:Home>Es learning notes (I): http request

Es learning notes (I): http request

2022-04-29 16:38:07Cloud cat lovers

 Insert picture description here

Video learning link :https://www.bilibili.com/video/BV1hh411D7sb

Basic knowledge of

Elastic search:

  • Open source highly extended distributed full-text search engine , Whole ES The core of the technology stack .
  • Near real-time storage 、 Retrieving data
  • Good scalability , Scalable to hundreds of servers , Handle PB Level of data
  • be based on Lucene Development (Lucene It provides the ability of Full-text Retrieval , But there is no way to use it directly )

introduction (mac edition )

Official website download address :https://www.elastic.co/cn/downloads/elasticsearch

  1. start-up :

    Enter the directory through the terminal elasticsearch-7.13.2/bin Next , perform command sh elasticsearch perhaps ./elasticsearch, You can start successfully
     Insert picture description here

    Partial startup log
     Insert picture description here

​ The result of browser access in the figure indicates that the startup is successful ( Be careful not to start repeatedly ):
 Insert picture description here

  1. stop it

    You can kill the process number , stop it es

    ps -ef |grep elastic

    kill -9 93467

  2. http Way to use ES

    Grammar official use document :https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html?baymax=rec&rogue=pop-1&elektra=docs

    Use postman establish

    An index is equivalent to a database , Document is equivalent to table

    action Request mode Address Parameters Idempotency remarks
    Create index PUThttp://127.0.0.1:9200/shoppingY
    Look at the index GEThttp://127.0.0.1:9200/shoppingY
    Delete index DELETEhttp://127.0.0.1:9200/shoppingY
    View all indexes GEThttp://127.0.0.1:9200/_cat/indices?vY
    Create documents under the index POSThttp://127.0.0.1:9200/shopping/_doc{“name”:“ Mi phones ”,“category”:“ millet ”,“price”:1000.00}N The same document can be stored multiple times , Each response id Different
    Create documents under the index ( Customize id)POSThttp://127.0.0.1:9200/shopping/_doc/1001{“name”:“ Mi phones ”,“category”:“ millet ”,“price”:1000.00}NPUT It's fine too ( The request for many times id unchanged , however version Will change , Similar to modifying the content )
    obtain shoping All the data below GEThttp://127.0.0.1:9200/shopping/_searchY
    Completely modify the data PUThttp://127.0.0.1:9200/shopping/_doc/1001{“name”:“ Mi phones ”,“category”:“ millet ”,“price”:4000.00}N
    Modify some data POSThttp://127.0.0.1:9200/shopping/_update/1001{“doc”:{“name”:“ Huawei mobile phones ”}}Y Ask many times version No increase
    Conditions of the query GEThttp://127.0.0.1:9200/shopping/_search?q=category: millet Path parameters
    Conditions of the query GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match”:{“category”:“ millet ”}}} Request body spelling parameters
    Paging query GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match_all”:{}},“from”:0,“size”:2}from: Page number , Calculation formula :( Page number -1)* Number of data bars per page ;size: Number of data bars per page
    Inquire about : Specify the display content GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match_all”:{}},“from”:0,“size”:2,"_source":[“name”,“price”]}
    Sort query GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match_all”:{}},"_source":[“name”,“price”],“sort”:{“price”:{“order”:“asc”}}} The sort price must be Numbers
    Link query andGEThttp://127.0.0.1:9200/shopping/_search{“query”:{“bool”:{“must”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}]}}}must
    Link query orGEThttp://127.0.0.1:9200/shopping/_search{“query”:{“bool”:{“should”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}]}}}should
    Range queries GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“bool”:{“should”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}],“filter”:{“range”:{“price”:{“gt”:4000.00}}}}}}filter
    Full text keyword search GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match_phrase”:{“category”:“ millet ”}}} Keyword search , No word segmentation for query conditions
    The search results are highlighted GEThttp://127.0.0.1:9200/shopping/_search{“query”:{“match_phrase”:{“category”:“ millet ”}},“highlight”:{“fields”:{“category”:{}}}} The return result increases html style
    Aggregate query : grouping {“aggs”:{“price_group”:{“terms”:{“field”:“price”}}}}aggs Represents an aggregate query ;price_group Group name Customize ;terms grouping . The results are grouped by field
    Aggregate query : Average {“aggs”:{“price_avg”:{“avg”:{“field”:“price”}}}}avg Average the fields
    http Create index mapping {“properties”:{“name”:{“type”:“text”,“index”:true},“sex”:{“type”:“keyword”,“index”:true},“tel”:{“type”:“keyword”,“index”:false}}}properties Index configuration ;name Document fields ;type:“text” Field type ;index Whether to create an index for this field ;keyword keyword , That is, no word segmentation is done for this attribute

copyright notice
author[Cloud cat lovers],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291420137656.html

Random recommended