Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create index and type in elastic search?

I have installed elasticsearch version 2.3.2. I have to add index and type to that elasticsearch. Before I used sense plugin to achieve this. But the addon was removed from webstore. Please give suggestion.

like image 470
Gopal Avatar asked Oct 16 '17 08:10

Gopal


People also ask

What is index and type in Elasticsearch?

In Elasticsearch, an index (plural: indices) contains a schema and can have one or more shards and replicas. An Elasticsearch index is divided into shards and each shard is an instance of a Lucene index. Indices are used to store the documents in dedicated data structures corresponding to the data type of fields.

How do you define type in Elasticsearch?

Basically, a type in Elasticsearch represented a class of similar documents and had a name such as customer or item . Lucene has no concept of document data types, so Elasticsearch would store the type name of each document in a metadata field of a document called _type.


2 Answers

You can use a Rest client like postman to do this. You can get the postman as a chrome extension.

The other way is to do an SSH into one of the nodes in your cluster and run the POST command using CURL.

`curl -X POST 'localhost:9200/bookindex/books' -H 'Content-Type: application/json' -d'
 {
    "bookId" : "A00-3",
    "author" : "Sankaran",
    "publisher" : "Mcgrahill",
    "name" : "how to get a job"
 }'

I will automatically create an index named 'bookindex' with type 'books' and index the data. If index and type already exist it will add the entry to the index.

like image 115
Keerthikanth Chowdary Avatar answered Oct 22 '22 13:10

Keerthikanth Chowdary


Sense plugin is now a Kibana app. Please refer official reference for installation.

The answer of your question is, you can create index and type in Elasticsearch by running below curl command

curl -XPUT "http://localhost:9200/IndexName/TypeName"
like image 9
Roopendra Avatar answered Oct 22 '22 12:10

Roopendra