2.X/1. Getting Started

1-03-02. Document Metadata

drscg 2017. 10. 1. 11:41

A document doesn’t consist only of its data. It also has metadata—information about the document.The three required metadata elements are as follows:

document가 데이터만으로 구성되어 있지는 않다. document에 대한 정보인 metadata 도 가지고 있다. 3개의 필수 metadata는 아래와 같다.

_index

Where the document lives

document가 존재하는 장소

_type

The class of object that the document represents

document를 대표하는 오브젝트 class

_id

The unique identifier for the document

document에 대한 유일한 id

_indexedit

An index is a collection of documents that should be grouped together for a common reason. For example, you may store all your products in a products index, while all your sales transactions go in sales. Although it is possible to store unrelated data together in a single index, it is often considered an anti-pattern.

index 는 동일한 이유로 함께 그룹화해야 하는 document의 집합이다. 예를 들자면, products index에는 모든 상품(product)을 저장하고, 반면에 sales 에는 모든 판매(sale) 사항을 저장할 것이다. 관련없는 데이터를 하나의 index에 함께 저장할 수 있지만, 그것은 추천하지 않는다.

Tip

Actually, in Elasticsearch, our data is stored and indexed in shards, while an index is just a logical namespace that groups together one or more shards. However, this is an internal detail; our application shouldn’t care about shards at all. As far as our application is concerned, our documents live in an index. Elasticsearch takes care of the details.

Elasticsearch에서, 데이터는 실제로 shard 에 저장되고 색인 된다. 반면에 index는 단지 하나 이상의 shard를 함께 모아 놓은, 논리적인 namespace이다. 그러나 이것은 내부적인 세부 사항이다. 응용프로그램은 shard에 대해 전혀 경 쓰지 않아도 된다. 응용프로그램에 있어서 만큼은, document는 index 에 있다. Elasticsearch가 그 세부 사항을 처리한다.

We cover how to create and manage indices ourselves in Index Management, but for now we will let Elasticsearch create the index for us. All we have to do is choose an index name. This name must be lowercase, cannot begin with an underscore, and cannot contain commas. Let’s use website as our index name.

indices를 생성하고 관리하는 방법에 대해서는 Index Management에서 이야기 할 것이다. 그러니 지금 index를 생성해 보자. 먼저 해야 할 일은 index의 이름을 결정하는 것이다. 그 이름은 반드시 소문자여야 한다. _(underscore)로 시작하거나 ,(comma)를 포함할 수 없다. index 이름을 website 로 하자.

_typeedit

Data may be grouped loosely together in an index, but often there are sub-partitions inside that data which may be useful to explicitly define. For example, all your products may go inside a single index. But you have different categories of products, such as "electronics", "kitchen" and "lawn-care".

index에서 데이터는 서로 느슨하게 그룹화될 것이다. 그러나, 해당 데이터 내에, 명시적으로 정의하는 것이 유용한 하위 범주가 흔히 있다. 예를 들자면, 모든 상품이 단일 index에 있겠지만, "electronics", "kitchen", "lawn-care" 같은, 제품 각각의 범주를 가진다.

The documents all share an identical (or very similar) schema: they have a title, description, product code, price. They just happen to belong to sub-categories under the umbrella of "Products".

document 모두는 동일한(또는 매우 유사한) schema를 공유한다: 그들은 title, description, product code, price를 가진다. 그들은 단지 "Products" 라는 범주 아래에 있는 하위 범주에 포함될 뿐이다.

Elasticsearch exposes a feature called types which allows you to logically partition data inside of an index. Documents in different types may have different fields, but it is best if they are highly similar. We’ll talk more about the restrictions and applications of types in Types and Mappings.

elasticsearch는 index 내부에서 데이터를 논리적으로 구분하는 types 라는 기능을 가진다. 다른 type에 있는 document는 다른 field를 가지겠지만, 매우 유사할 것이다. Types and Mappings에서 type의 제한사항과 적용에 대해 더 많이 이야기할 것이다.

_type name can be lowercase or uppercase, but shouldn’t begin with an underscore or period. It also may not contain commas, and is limited to a length of 256 characters. We will use blog for our type name.

_type 의 이름은 소문자나 대문자일 수 있다. 그러나 _(underscore)로 시작하거나, ,(comma)를 포함할 수 없다. type의 이름을 user 로 하자.

_idedit

The ID is a string that, when combined with the _index and _type, uniquely identifies a document in Elasticsearch. When creating a new document, you can either provide your own _id or let Elasticsearch generate one for you.

ID 는 Elasticsearch에서, _index_type 과 함께 조합되어, document를 유일하게 식별할 수 있는 문자열이다. document를 생성할 때, 사용자가 자신의 _id 를 제공하거나, Elasticsearch가 생성하도록 할 수 있다.

Other Metadataedit

There are several other metadata elements, which are presented in Types and Mappings. With the elements listed previously, we are already able to store a document in Elasticsearch and to retrieve it by ID—in other words, to use Elasticsearch as a document store.

여러 가지 다른 metadata가 있는데, 그것은 Types and Mappings에서 이야기 할 것이다. 위에서 언급한 요소들로, 이미 Elasticsearch에 document를 저장할 수 있고, ID를 이용하여 검색할 수 있다. 즉, document 저장소로서 Elasticsearch를 사용할 수 있다는 것이다.


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

1-03. Data In, Data Out  (0) 2017.10.01
1-03-01. What Is a Document?  (0) 2017.10.01
1-03-03. Indexing a Document  (0) 2017.10.01
1-03-04. Retrieving a Document  (0) 2017.10.01
1-03-05. Checking Whether a Document Exists  (0) 2017.10.01