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 :

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 :

  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 :

    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://
    Look at the index GEThttp://
    Delete index DELETEhttp://
    View all indexes GEThttp://
    Create documents under the index POSThttp://{“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://{“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://
    Completely modify the data PUThttp://{“name”:“ Mi phones ”,“category”:“ millet ”,“price”:4000.00}N
    Modify some data POSThttp://{“doc”:{“name”:“ Huawei mobile phones ”}}Y Ask many times version No increase
    Conditions of the query GEThttp:// millet Path parameters
    Conditions of the query GEThttp://{“query”:{“match”:{“category”:“ millet ”}}} Request body spelling parameters
    Paging query GEThttp://{“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://{“query”:{“match_all”:{}},“from”:0,“size”:2,"_source":[“name”,“price”]}
    Sort query GEThttp://{“query”:{“match_all”:{}},"_source":[“name”,“price”],“sort”:{“price”:{“order”:“asc”}}} The sort price must be Numbers
    Link query andGEThttp://{“query”:{“bool”:{“must”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}]}}}must
    Link query orGEThttp://{“query”:{“bool”:{“should”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}]}}}should
    Range queries GEThttp://{“query”:{“bool”:{“should”:[{“match”:{ “category”:“ millet ”}},{“match”:{“price”:1000.00}}],“filter”:{“range”:{“price”:{“gt”:4000.00}}}}}}filter
    Full text keyword search GEThttp://{“query”:{“match_phrase”:{“category”:“ millet ”}}} Keyword search , No word segmentation for query conditions
    The search results are highlighted GEThttp://{“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.

Random recommended