How to insert data into elasticsearch

后端 未结 7 2076
情深已故
情深已故 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 15:09

    If you are using KIBANA with elasticsearch then you can use below RESt request to create and put in the index.

    CREATING INDEX:

    http://localhost:9200/company
    PUT company
    {
      "settings": {
        "index": {
          "number_of_shards": 1,
          "number_of_replicas": 1
        },
        "analysis": {
          "analyzer": {
            "analyzer-name": {
              "type": "custom",
              "tokenizer": "keyword",
              "filter": "lowercase"
            }
          }
        }
      },
      "mappings": {
        "employee": {
          "properties": {
            "age": {
              "type": "long"
            },
            "experience": {
              "type": "long"
            },
            "name": {
              "type": "text",
              "analyzer": "analyzer-name"
            }
          }
        }
      }
    }
    

    CREATING DOCUMENT:

    POST http://localhost:9200/company/employee/2/_create
    {
    "name": "Hemani",
    "age" : 23,
    "experienceInYears" : 2
    }
    
    0 讨论(0)
提交回复
热议问题