Multiplexer token filter
출처: 문서
본문
Multiplexer 토큰 필터
multiplexer 토큰 필터는 다른 필터를 적용하여 동일한 토큰의 여러 버전을 만들 수 있게 해요. 이는 동일한 토큰을 여러 방식으로 분석하고 싶을 때 유용해요. 예를 들어, 다른 형태소 분석, 동의어, 또는 n-gram 필터를 사용하여 토큰을 분석하고 생성된 모든 토큰을 함께 사용하고 싶을 수 있어요. 이 토큰 필터는 토큰 스트림을 복제하고 각 복사본에 다른 필터를 적용하여 작동해요.
multiplexer 토큰 필터는 토큰 스트림에서 중복 토큰을 제거해요.
{: .important}
multiplexer 토큰 필터는 다중 단어 synonym 또는 synonym_graph 토큰 필터나 shingle 토큰 필터를 지원하지 않아요. 입력을 올바르게 변환하기 위해 현재 토큰뿐만 아니라 이후 토큰도 분석해야 하기 때문이에요.
{: .important}
Parameters
multiplexer 토큰 필터는 다음 매개변수로 구성할 수 있어요.
| Parameter | Required/Optional | Data type | Description |
|---|---|---|---|
filters |
Optional | List of strings | 토큰 스트림의 각 복사본에 적용할 토큰 필터의 쉼표로 구분된 목록이에요. 기본값은 빈 목록이에요. |
preserve_original |
Optional | Boolean | 원래 토큰을 출력 중 하나로 유지할지 여부예요. 기본값은 true예요. |
Example
다음 예제 요청은 multiplexer_index라는 새 인덱스를 생성하고 multiplexer 필터로 분석기를 구성해요.
PUT /multiplexer_index
{
"settings": {
"analysis": {
"filter": {
"english_stemmer": {
"type": "stemmer",
"name": "english"
},
"synonym_filter": {
"type": "synonym",
"synonyms": [
"quick,fast"
]
},
"multiplexer_filter": {
"type": "multiplexer",
"filters": ["english_stemmer", "synonym_filter"],
"preserve_original": true
}
},
"analyzer": {
"multiplexer_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"multiplexer_filter"
]
}
}
}
}
}
{% include copy-curl.html %}
Generated tokens
다음 요청을 사용하여 분석기로 생성된 토큰을 확인해요.
POST /multiplexer_index/_analyze
{
"analyzer": "multiplexer_analyzer",
"text": "The slow turtle hides from the quick dog"
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 포함되어 있어요.
{
"tokens": [
{
"token": "The",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "slow",
"start_offset": 4,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "turtle",
"start_offset": 9,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "turtl",
"start_offset": 9,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "hides",
"start_offset": 16,
"end_offset": 21,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "hide",
"start_offset": 16,
"end_offset": 21,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "from",
"start_offset": 22,
"end_offset": 26,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "the",
"start_offset": 27,
"end_offset": 30,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "quick",
"start_offset": 31,
"end_offset": 36,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "fast",
"start_offset": 31,
"end_offset": 36,
"type": "SYNONYM",
"position": 6
},
{
"token": "dog",
"start_offset": 37,
"end_offset": 40,
"type": "<ALPHANUM>",
"position": 7
}
]
}