Kim-Baek 개발자 이야기

[Elasticsearch] Index API 본문

개발/Elasticsearch

[Elasticsearch] Index API

킴백 개발자 2020. 8. 10. 03:00

Index API

  • Index API를 이용해 JSON Document를 특정 index에 insert, update 할 수 있다.

 

Create index & Delete index

 # Check Cluster Health
 curl -XGET 'localhost:9200/_cat/health?v&pretty'

 # Create index
 curl -XPUT 'localhost:9200/myIndex'

 # Get all indexing
 curl -XGET 'localhost:9200/_cat/indices?pretty'

 # Delte index
 curl -XDELETE 'localhost:9200/myIndex'

 

Insert Document & Query

 

Insert Document
PUT {index}/{type}/{id}

id를 지정해 주지 않으면 id가 자동으로 생성된다.

 

Query Documnet


GET {index}/{type}/{id}

  # Insert Document
  curl -XPUT 'localhost:9200/myIndex/user/1?pretty&pretty' -d'
  {
    "name": "John Doe"
  }'

  # Query Document
  curl -XGET 'localhost:9200/myIndex/user/1?pretty&pretty'

 

Versioning

 

Reference

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html

반응형

'개발 > Elasticsearch' 카테고리의 다른 글

[Elasticsearch] Aggregation  (0) 2020.08.12
[Elasticsearch] Mapping API  (0) 2020.08.11
[Elasticsearch] 기본 개념, Concept, 용어  (0) 2020.08.09
Comments