# 6.6.5 Unique

&#x20; **"white fox, white rabbit, white bear"** 같은 문장을 분석하면 **"white"** 텀은 총 3번 저장이 됩니다. 역 색인에는 텀이 1개만 있어도 텀을 포함하는 도큐먼트를 가져올 수 있기 때문에 중복되는 텀 들은 삭제 해 주어도 검색에는 보통 무방합니다. 이 경우 **unique** 토큰 필터를 사용해서 중복되는 텀 들은 하나만 저장하도록 할 수 있습니다.&#x20;

&#x20; 다음은 **"white fox, white rabbit, white bear"** 문장을 **unique** 토큰 필터를 적용하지 않은 경우와 적용한 경우를 비교 한 예제입니다.

{% tabs %}
{% tab title="request" %}
{% code title="일반적인 "white fox, white rabbit, white bear" 문장 분석" %}

```javascript
GET _analyze
{
  "tokenizer": "standard",
  "filter": [
    "lowercase"
  ],
  "text": [
    "white fox, white rabbit, white bear"
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="response" %}
{% code title="일반적인 "white fox, white rabbit, white bear" 문장 분석 결과" %}

```javascript
{
  "tokens" : [
    {
      "token" : "white",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "fox",
      "start_offset" : 6,
      "end_offset" : 9,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "white",
      "start_offset" : 11,
      "end_offset" : 16,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "rabbit",
      "start_offset" : 17,
      "end_offset" : 23,
      "type" : "<ALPHANUM>",
      "position" : 3
    },
    {
      "token" : "white",
      "start_offset" : 25,
      "end_offset" : 30,
      "type" : "<ALPHANUM>",
      "position" : 4
    },
    {
      "token" : "bear",
      "start_offset" : 31,
      "end_offset" : 35,
      "type" : "<ALPHANUM>",
      "position" : 5
    }
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="request" %}
{% code title="unique 토크나이저로 "white fox, white rabbit, white bear" 문장 분석" %}

```javascript
GET _analyze
{
  "tokenizer": "standard",
  "filter": [
    "lowercase",
    "unique"
  ],
  "text": [
    "white fox, white rabbit, white bear"
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="response" %}
{% code title="unique 토크나이저로 "white fox, white rabbit, white bear" 문장 분석 결과" %}

```javascript
{
  "tokens" : [
    {
      "token" : "white",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "fox",
      "start_offset" : 6,
      "end_offset" : 9,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "rabbit",
      "start_offset" : 17,
      "end_offset" : 23,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "bear",
      "start_offset" : 31,
      "end_offset" : 35,
      "type" : "<ALPHANUM>",
      "position" : 3
    }
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

&#x20; `"unique"` 토큰 필터를 적용하면 **"white"** 텀이 하나만 저장된 것을 확인할 수 있습니다.

{% hint style="danger" %}
match 쿼리를 사용해서 검색하는 경우 unique 토큰 필터를 적용한 필드는 텀의 개수가 1개로 되기 때문에 **TF(Term Frequency)** 값이 줄어들어 스코어 점수가 달라질 수 있습니다. match 쿼리를 이용해 **정확도(relevancy)** 를 따져야 하는 검색의 경우에는 unique 토큰 필터는 사용하지 않는 것이 바람직합니다.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://esbook.kimjmin.net/06-text-analysis/6.6-token-filter/6.6.5-unique.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
