2.X/1. Getting Started

1-08-4. Doc Values Intro

drscg 2017. 9. 30. 18:07

Our final topic in this chapter is about an internal aspect of Elasticsearch. While we don’t demonstrate any new techniques here, doc values are an important topic that we will refer to repeatedly, and is something that you should be aware of.

이 장의 마지막 주제는 Elasticsearch의 내부에 대한 것이다. 여기에서는 새로운 기술을 보여주지는 않지만, doc values는 반복적으로 언급할 중요한 주제이며, 알아야 한다.

When you sort on a field, Elasticsearch needs access to the value of that field for every document that matches the query. The inverted index, which performs very well when searching, is not the ideal structure for sorting on field values:

field를 정렬할 때, Elasticsearch는 query에 일치하는 모든 document에 대해, 해당 field 값을 액세스해야 한다. 검색 시에 매우 잘 동작하는 inverted index는, field값으로 정렬하는 경우에는, 이상적인 구조가 아니다.

  • When searching, we need to be able to map a term to a list of documents.

    검색 시에는, 단어를 document의 목록에 mapping해야 한다.

  • When sorting, we need to map a document to its terms. In other words, we need to "uninvert" the inverted index.

    정렬 시에는, document를 단어에 mapping해야 한다. 즉, inverted index를 "uninvert" 해야 한다.

This "uninverted" structure is often called a "column-store" in other systems. Essentially, it stores all the values for a single field together in a single column of data, which makes it very efficient for operations like sorting.

이 "uninverted" 구조는 다른 시스템에서 흔히 "column-store" 라 불린다. 기본적으로, 단일 field에 대한 모든 값을 데이터의 단일 칼럼에 함께 저장한다. 이것은 정렬 같은 연산에 매우 효율적이다.

In Elasticsearch, this column-store is known as doc values, and is enabled by default. Doc values are created at index-time: when a field is indexed, Elasticsearch adds the tokens to the inverted index for search. But it also extracts the terms and adds them to the columnar doc values.

elasticsearch에서 column-store는 doc values 라 알려져 있고, 기본적으로 활성화되어 있다. doc values는 색인 시점에 생성된다. field가 색인되면, elasticsearch는 검색을 위해 inverted index에 token을 추가한다. 그러나 그것은 또한 단어를 추출하고, 컬럼 형식의 doc values에 단어를 추가한다.

Doc values are used in several places in Elasticsearch:

doc values는 elasticsearch에서 여러 곳에 사용된다.

  • Sorting on a field, field의 정렬
  • Aggregations on a field, field의 aggregation
  • Certain filters (for example, geolocation filters), 특정 filter(예를 들자면, geolocation filters)
  • Scripts that refer to fields, field를 참고하는 script

Because doc values are serialized to disk, we can leverage the OS to help keep access fast. When the "working set" is smaller than the available memory on a node, the OS will naturally keep all the doc values hot in memory, leading to very fast access. When the "working set" is much larger than available memory, the OS will naturally start to page doc-values on/off disk without running into the dreaded OutOfMemory exception.

doc values는 disk에 저장되기 때문에, 빠르게 액세스하도록 OS를 조정할 수 있다. 어떤 node에서 "working set" 이 이용할 수 있는 메모리보다 작을 경우, OS는 당연히 모든 doc values를 memory에 유지할 것이고, 매우 바르게 액세스로 이어진다. "working set" 이 이용할 수 있는 메모리보다 훨씬 크다면, OS는 당연히 심각한 OutOfMemory exception을 피하기 위해 doc values를 disk에 paging하기 시작할 것이다.

We’ll talk about doc values in much greater depth later. For now, all you need to know is that sorting (and some other operations) happen on a parallel data structure which is built at index-time.

나중에 doc values에 대해 훨씬 더 자세히 이야기할 것이다. 우선 알아야할 모든 것은 정렬(그리고 몇몇 다른 연산)은 색인시에 생성된 병렬 데이터 구조에서 일어난다는 것이다.

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

1-08-2. String Sorting and Multifields  (0) 2017.09.30
1-08-3. What Is Relevance?  (0) 2017.09.30
1-09. Distributed Search Execution  (0) 2017.09.30
1-09-1. Query Phase  (0) 2017.09.30
1-09-2. Fetch Phase  (0) 2017.09.30