How to insert data into elasticsearch

后端 未结 7 2075
情深已故
情深已故 2020-12-23 14:47

I am new to Elasticearch, and I have been trying for 2 days to insert some data into Elasticearch. I found on Google that there are many pages to help to create an index (I

相关标签:
7条回答
  • 2020-12-23 14:54

    Simple fundamentals, Elastic community has exposed indexing, searching, deleting operation as rest web service. You can interact elastic using curl or sense(chrome plugin) or any rest client like postman.

    If you are just testing few commands, I would recommend can use of sense chrome plugin which has simple UI and pretty mature plugin now.

    0 讨论(0)
  • 2020-12-23 14:58

    To test and try curl requests from Windows, you can make use of Postman client Chrome extension. It is very simple to use and quite powerful.

    Or as suggested you can install the cURL util.

    A sample curl request is as follows.

    curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
    "user" : "Arun Thundyill Saseendran",
    "post_date" : "2009-03-23T12:30:00",
    "message" : "trying out Elasticsearch"
    }' "http://10.103.102.56:9200/sampleindex/sampletype/"
    

    I am also getting started with and exploring ES in vast. So please let me know if you have any other doubts.

    EDIT: Updated the index name and type name to be fully lowercase to avoid errors and follow convention.

    0 讨论(0)
  • 2020-12-23 14:59

    Let me explain clearly.. If you are familiar With rdbms.. Index is database.. And index type is table.. It mean index is collection of index types., like collection of tables as database (DB).

    in NOSQL.. Index is database and index type is collections. Group of collection as database..

    To execute those queries... U need to install CURL for Windows.

    Curl is nothing but a command line rest tool.. If you want a graphical tool.. Try

    Sense plugin for chrome...

    Hope it helps..

    0 讨论(0)
  • 2020-12-23 15:00

    To avoid using curl or Chrome plugins you can just use the the built in windows Powershell. From the Powershell command window run

    Invoke-WebRequest -UseBasicParsing "http://127.0.0.1:9200/sampleindex/sampleType/" -
    Method POST -ContentType "application/json" -Body '{
    "user" : "Test",
    "post_date" : "2017/11/13 11:07:00",
    "message" : "trying out Elasticsearch"
    }'
    

    Note the Index name MUST be in lowercase.

    0 讨论(0)
  • 2020-12-23 15:02

    You have to install the curl binary in your PC first. You can download it from here.

    After that unzip it into a folder. Lets say C:\curl. In that folder you'll find curl.exe file with several .dll files.

    Now open a command prompt by typing cmd from the start menu. And type cd c:\curl on there and it will take you to the curl folder. Now execute the curl command that you have.

    One thing, windows doesn't support single quote around around the fields. So you have to use double quotes. For example I have converted your curl command like appropriate one.

    curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/indexname/typename/optionalUniqueId" -d "{ \"field\" : \"value\"}"
    
    0 讨论(0)
  • 2020-12-23 15:04

    I started off using curl, but since have migrated to use kibana. Here is some more information on the ELK stack from elastic.co (E elastic search, K kibana): https://www.elastic.co/elk-stack

    With kibana your POST requests are a bit more simple:

    POST /<INDEX_NAME>/<TYPE_NAME>
    {
        "field": "value",
        "id": 1,
        "account_id": 213,
        "name": "kimchy"
    }
    
    0 讨论(0)
提交回复
热议问题