2.X/1. Getting Started

1-01-03. Document Oriented

drscg 2017. 10. 1. 12:22

Objects in an application are seldom just a simple list of keys and values. More often than not, they are complex data structures that may contain dates, geo locations, other objects, or arrays of values.

응용프로그램의 오브젝트가 단순히 간단한 Key/Value의 목록인 경우는 거의 없다. 보통 오브젝트는 날짜, 위치정보, 다른 오브젝트, 값의 배열을 포함하고 있는 복잡한 구조이다.

Sooner or later you’re going to want to store these objects in a database. Trying to do this with the rows and columns of a relational database is the equivalent of trying to squeeze your rich, expressive objects into a very big spreadsheet: you have to flatten the object to fit the table schema—usually one field per column—and then have to reconstruct it every time you retrieve it.

여러분은 이런 오브젝트를 데이터베이스에 저장하려고 할 것이다. 이를 RDB(Relational DataBase)의 row와 column에 저장하려고 하는 것은 매우 큰 spreadsheet에 오브젝트((rich expressive objects)를 밀어 넣으려고 하는 것과 같다. table schema(일반적으로 column 당 하나의 field)에 맞추기 위해, 오브젝트를 평면화 시켜야 한다. 그리고 그것을 다시 가져올 때마다 다시 만들어야 한다.

Elasticsearch is document oriented, meaning that it stores entire objects or documents. It not only stores them, but also indexes the contents of each document in order to make them searchable. In Elasticsearch, you index, search, sort, and filter documents—not rows of columnar data. This is a fundamentally different way of thinking about data and is one of the reasons Elasticsearch can perform complex full-text search.

Elasticsearch는 document oriented 하다. 즉, 오브젝트나 document 전체를 저장한다. 저장할 뿐만 아니라, 그것을 검색할 수 있도록, 각 document의 내용을 색인(index) 한다. Elasticsearch에서, document를 색인하고, 검색하고, 정렬하고, filtering한다. column으로 나누어진 데이터의 row가 아니다. 이는 데이터에 대한 생각이 근본적으로 다른 방식이며, Elasticsearch가 복잡한 full-text 검색을 할 수 있는 이유 중의 하나이다.

JSONedit

Elasticsearch uses JavaScript Object Notation, or JSON, as the serialization format for documents. JSON serialization is supported by most programming languages, and has become the standard format used by the NoSQL movement. It is simple, concise, and easy to read.

Elasticsearch는 document의 직렬화(serialization) 형식으로, JSON(JavaScript Object Notation)을 사용한다. JSON 직렬화는 대부분의 programming language에서 지원되며, NoSQL 진영에서 사용되는 표준 형식이 되었다. JSON은 간단하고, 간결하며, 읽기가 쉽다.

Consider this JSON document, which represents a user object:

어떤 사용자를 나타내는 오브젝트의, JSON document를 살펴보자.

{
    "email":      "john@smith.com",
    "first_name": "John",
    "last_name":  "Smith",
    "info": {
        "bio":         "Eco-warrior and defender of the weak",
        "age":         25,
        "interests": [ "dolphins", "whales" ]
    },
    "join_date": "2014/05/01"
}

Although the original user object was complex, the structure and meaning of the object has been retained in the JSON version. Converting an object to JSON for indexing in Elasticsearch is much simpler than the equivalent process for a flat table structure.

원래의 user 오브젝트는 복잡하지만, JSON 버전은 오브젝트가 가지고 있는 구조와 의미를 가지고 있다. Elasticsearch에 색인하기 위해, 어떤 오브젝트를 JSON으로 바꾸는 것은 평면적인 table 구조로 바꾸는 것보다 훨씬 쉽다.

Note

Almost all languages have modules that will convert arbitrary data structures or objectsinto JSON for you, but the details are specific to each language. Look for modules that handle JSON serialization or marshalling. The official Elasticsearch Clients all handle conversion to and from JSON for you automatically.

대부분의 언어는 임의의 데이터 구조나 오브젝트를 JSON으로 바꾸는 module을 가지고 있다. 하지만, 자세한 방법은 각 language마다 독특하다. JSON serialization 이나 marshalling을 다루는 module을 찾아보기 바란다. 공식적인 Elasticsearch Clients는 자동으로 JSON으로 바꾸거나, JSON으로부터 가져오는 변환, 모두를 지원한다.


'2.X > 1. Getting Started' 카테고리의 다른 글

1-01-01. Installing and Running Elasticsearch  (0) 2017.10.01
1-01-02. Talking to Elasticsearch  (0) 2017.10.01
1-01-04. Finding Your Feet  (0) 2017.10.01
1-01-05. Indexing Employee Documents  (0) 2017.10.01
1-01-06. Retrieving a Document  (0) 2017.10.01