2.X/1. Getting Started

1-06-1. Exact Values Versus Full Text

drscg 2017. 9. 30. 20:45

Data in Elasticsearch can be broadly divided into two types: exact values and full text.

Elasticsearch에서 데이터는 크게 두 가지(exact value와 full text) 형태로 나누어진다.

Exact values are exactly what they sound like. Examples are a date or a user ID, but can also include exact strings such as a username or an email address. The exact value Foo is not the same as the exact value foo. The exact value 2014 is not the same as the exact value 2014-09-15.

exact values 는 말 그대로 정확하다는 것이다. 예로는 날짜, 사용자 ID, 뿐만 아니라, 사용자 이름, email 주소 같은 정확한 문자열을 포함한다. exact value Foo 는 exact value foo 와 동일하지 않다. exact value 2014 는 exact value 2014-09-15 와 동일하지 않다.

Full text, on the other hand, refers to textual data—usually written in some human language — like the text of a tweet or the body of an email.

반면에, full text 는 tweet의 텍스트나 email의 본문처럼, 일반적으로 사람의 언어로 쓰여진 텍스트 데이터를 나타낸다.

Note

Full text is often referred to as unstructured data, which is a misnomer—natural language is highly structured. The problem is that the rules of natural languages are complex, which makes them difficult for computers to parse correctly. For instance, consider this sentence:

full text는 종종 구조화되지 않은 데이터(unstructured data) 라고 하는데, 이는 부적절한 명칭이다. 자연어는 고도로 구조화되어 있다. 자연어의 규칙을 computer가 올바르게 해석하는 것이 어려울 정도로 복잡하다는 것이 문제이다. 예를 들어, 다음 문장을 살펴보자.

May is fun but June bores me.

Does it refer to months or to people?

달(month)을 언급하는지? 사람을 언급하는것인지?

Exact values are easy to query. The decision is binary; a value either matches the query, or it doesn’t. This kind of query is easy to express with SQL:

exact value는 query하기가 쉽다. 결론은 query에 일치하거나 그렇지 않거나 둘 중의 하나이다. 이런 종류의 query는 SQL로 표현하는 것이 쉽다.

WHERE name    = "John Smith"
  AND user_id = 2
  AND date    > "2014-09-15"

Querying full-text data is much more subtle. We are not just asking, "Does this document match the query" but "How well does this document match the query?" In other words, how relevant is this document to the given query?

full-text 데이터를 query하는 것은 휠씬 더 미묘하다. "이 document가 query에 일치합니까?" 가 아닌 "이 document가 query에 얼마나  일치합니까", 즉, "document가 주어진 query에 얼마나 관련(relevant) 있습니까?" 라고 질문한다.

We seldom want to match the whole full-text field exactly. Instead, we want to search within text fields. Not only that, but we expect search to understand our intent:

전체 full-text field가 정확히 일치하기를 바라는 경우는 거의 없다. 대신 text field 내부 를 검색하려 한다. 뿐만 아니라 우리의 의도 를 이해하는 검색을 기대한다.

  • A search for UK should also return documents mentioning the United Kingdom.

    UK 에 대한 검색은, United Kingdom 을 언급하는 document도 반환해야 한다.

  • A search for jump should also match jumpedjumpsjumping, and perhaps even leap.

    jump 에 대한 검색은, jumpedjumps 그리고 jumping 심지어 leap 과도 일치해야 한다.

  • johnny walker should match Johnnie Walker, and johnnie depp should match Johnny Depp.

    johnny walker 에 대한 검색은 johnnie walker 와 일치해야 하고, johnnie depp 은 johnny Depp과 일치해야 한다.

  • fox news hunting should return stories about hunting on Fox News, while fox hunting newsshould return news stories about fox hunting.

    fox news hunting 은 Fox News에서 hunting에 대한 뉴스를 반환해야 하고, 반면에 fox hunting news 는 fox hunting에 대한 news를 반환해야 한다.

To facilitate these types of queries on full-text fields, Elasticsearch first analyzes the text, and then uses the results to build an inverted index. We will discuss the inverted index and the analysis process in the next two sections.

full-text field에 대해, 이런 유형의 query를 용이하게 하기 위해서, Elasticsearch는 먼저 문장(text)을 분석(analyze) 하고, 그 결과를 inverted index 를 만드는데 사용한다. inverted index와 분석(analysis) 프로세스에 대해 이야기 해 보자.

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

1-05-4. Search Lite  (0) 2017.09.30
1-06. Mapping and Analysis  (0) 2017.09.30
1-06-2. Inverted Index  (0) 2017.09.30
1-06-3. Analysis and Analyzers  (0) 2017.09.30
1-06-4. Mapping  (0) 2017.09.30