Docs Menu
Docs Home
/
Atlas
/ / / /

멀티 분석기

이 페이지의 내용

  • 다중 분석기 제한 사항
  • 예시
  • 단일 필드 예시
  • 여러 필드 예시

인덱스 정의에서 객체 사용하여 필드 도 인덱스 할 대체 분석기를 지정할 수 있습니다. 기본값 분석기 외에 대체 분석기를 사용하여 필드 인덱스 경우 기본값 또는 대체 분석기 사용하여 컬렉션 을 검색 할 수 있습니다. 이 페이지에서는 를 multi 사용하여인덱스 정의에서 대체 분석기를 지정하는 방법을 multi 설명합니다.

multi경로 옵션은 문자열 유형의 필드에만 사용할 수 있습니다.

Atlas Search는 multi 객체의 다중 계층 중첩을 지원하지 않습니다.

다음 예시는 sample_mflix.movies 컬렉션의 필드에 대한 인덱스 정의를 보여줍니다. 클러스터에 컬렉션을 로드한 경우, Atlas UI에서 비주얼 편집기 또는 JSON 편집기를 사용하여 예시 인덱스를 만들 수 있습니다. 선호하는 구성 방법을 선택한 후 데이터베이스와 컬렉션을 선택하여 인덱스를 정의하세요.

다음 예시 인덱스 정의는 standard 분석기를 사용하여 title 필드에 대한 인덱스를 지정합니다. 또한 인덱스 정의에서는 lucene.french 분석기를 title 필드의 대체 분석기로 지정합니다(이름은 frenchAnalyzer).

  1. 인덱스를 구성하려면 Refine Your Index를 클릭합니다.

  2. Field Mappings 섹션에서 Add Field 을 클릭하여 Add Field Mapping창을 엽니다.

  3. Field Name 드롭다운 메뉴에서 title을(를) 선택합니다.

  4. Data Type 드롭다운을 클릭하고 아직 선택되지 않은 경우 String을(를) 선택합니다.

  5. String Properties을 확장하고 다음과 같이 변경합니다:

    인덱스 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.standard을(를) 선택합니다.

    검색 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.standard을(를) 선택합니다.

    인덱스 옵션

    기본값 offsets을(를) 사용합니다.

    Store

    기본값 true을(를) 사용합니다.

    위 내용 무시

    기본 설정을 유지합니다.

    규범

    기본값 include을(를) 사용합니다.

  6. title 필드에 다른 분석기를 구성하려면 Add Multi Field 을 클릭합니다.

  7. Multi Field Name 필드에 frenchAnalyzer 을 입력합니다.

  8. 다음과 같이 Multi Field Properties 을 변경합니다:

    인덱스 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.french을(를) 선택합니다.

    검색 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.french을(를) 선택합니다.

    인덱스 옵션

    기본값 offsets을(를) 사용합니다.

    Store

    기본값 true을(를) 사용합니다.

    위 내용 무시

    기본 설정을 유지합니다.

    규범

    기본값 include을(를) 사용합니다.

  9. Add를 클릭합니다.

  10. Save Changes를 클릭합니다.

  11. Create Search Index를 클릭합니다.

  1. 기본 인덱스 정의를 다음 인덱스 정의로 바꾸세요.

    1{
    2 "mappings": {
    3 "dynamic": false,
    4 "fields": {
    5 "title": {
    6 "type": "string",
    7 "analyzer": "lucene.standard",
    8 "multi": {
    9 "frenchAnalyzer": {
    10 "type": "string",
    11 "analyzer": "lucene.french"
    12 }
    13 }
    14 }
    15 }
    16 }
    17}
  2. Next를 클릭합니다.

  3. Create Search Index를 클릭합니다.

다음 쿼리는 frenchAnalyzer라는 대체 분석기를 사용하여 문자열 liberte를 검색합니다.

1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "query": "liberte",
6 "path": { "value": "title", "multi": "frenchAnalyzer" }
7 }
8 }
9 },
10 {
11 "$project": {
12 "title": 1,
13 "year": 1,
14 "_id": 0
15 }
16 }
17])
[ { title: 'è Nous la Libertè', year: 1931 } ]

frenchAnalyzer가 인덱스 문자열 è Nous la Libertè 및 쿼리 텀 liberte를 기본 단어 libert로 줄였기 때문에 결과의 문서가 일치합니다. Atlas Search는 standard 분석기를 사용한 검색에서 이 문서를 반환하지 않습니다. 해당 분석기가 발음 구별 기호를 제거하지 않기 때문입니다. 각 분석기는 인덱스와 쿼리에 대해 다음과 같은 토큰(검색 가능한 텀)을 생성합니다.

분석기
Index Tokens
쿼리 토큰

표준 분석기

è, nous, la, libertè

libertè

프랑스어 분석기

è, libert

libert

다음 예시 인덱스 정의는 standard 분석기를 사용하여 titleplot 필드에 대한 인덱스를 지정합니다. 인덱스 정의는 또한 titleplot 필드에 대한 대체 분석기로 lucene.french를 지정합니다.

  1. 인덱스를 구성하려면 Refine Your Index을(를) 클릭합니다.

  2. Field Mappings 섹션에서 Add Field 을 클릭하여 Add Field Mapping창을 엽니다.

  3. Field Name 드롭다운 메뉴에서 title을(를) 선택합니다.

  4. Data Type 드롭다운을 클릭하고 아직 선택되지 않은 경우 String을(를) 선택합니다.

  5. String Properties을 확장하고 다음과 같이 변경합니다:

    인덱스 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.standard을(를) 선택합니다.

    검색 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.standard을(를) 선택합니다.

    인덱스 옵션

    기본값 offsets을(를) 사용합니다.

    Store

    기본값 true을(를) 사용합니다.

    위 내용 무시

    기본 설정을 유지합니다.

    규범

    기본값 include을(를) 사용합니다.

  6. title 필드에 다른 분석기를 구성하려면 Add Multi Field 을 클릭합니다.

  7. Multi Field Name 필드에 frenchAnalyzer 을 입력합니다.

  8. 다음과 같이 Multi Field Properties 을 변경합니다:

    인덱스 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.french을(를) 선택합니다.

    검색 분석기

    아직 선택되지 않은 경우 드롭다운에서 lucene.french을(를) 선택합니다.

    인덱스 옵션

    기본값 offsets을(를) 사용합니다.

    Store

    기본값 true을(를) 사용합니다.

    위 내용 무시

    기본 설정을 유지합니다.

    규범

    기본값 include을(를) 사용합니다.

  9. Add를 클릭합니다.

  10. Add Field Mapping 을 클릭하여 Add Field Mapping 창을 엽니다.

  11. Field Name 드롭다운 메뉴에서 plot을(를) 선택합니다.

  12. 4부터 9까지 단계를 반복합니다.

  13. Save Changes를 클릭합니다.

  14. Create Search Index를 클릭합니다.

  1. 기본 인덱스 정의를 다음 인덱스 정의로 바꾸세요.

    1{
    2 "mappings": {
    3 "dynamic": false,
    4 "fields": {
    5 "title": {
    6 "type": "string",
    7 "analyzer": "lucene.standard",
    8 "multi": {
    9 "frenchAnalyzer": {
    10 "type": "string",
    11 "analyzer": "lucene.french"
    12 }
    13 }
    14 },
    15 "plot": {
    16 "type": "string",
    17 "analyzer": "lucene.standard",
    18 "multi": {
    19 "frenchAnalyzer": {
    20 "type": "string",
    21 "analyzer": "lucene.french"
    22 }
    23 }
    24 }
    25 }
    26 }
    27}
  2. Next를 클릭합니다.

  3. Create Search Index를 클릭합니다.

다음 쿼리는 frenchAnalyzer라는 대체 분석기를 사용하여 titleplot 필드에서 revolution 문자열과 일치하는 항목을 검색합니다.

1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "query": "revolution",
6 "path": ["title", "plot",
7 { "value": "title", "multi": "frenchAnalyzer" },
8 { "value": "plot", "multi": "frenchAnalyzer" }
9 ]
10 }
11 }
12 },
13 {
14 "$limit": 5
15 },
16 {
17 "$project": {
18 "title": 1,
19 "plot": 1,
20 "year": 1,
21 "_id": 0
22 }
23 }
24])
[
{
year: 2012,
plot: 'REVOLUTION is a film about changing the world, going for it, taking a stand, and fighting for something. A true-life adventure following Director, Rob Stewart (SHARKWATER) over four years ...',
title: 'Revolution'
},
{
plot: 'New York trapper Tom Dobb becomes an unwilling participant in the American Revolution after his son Ned is drafted into the Army by the villainous Sergeant Major Peasy. Tom attempts to find...',
title: 'Revolution',
year: 1985
},
{
plot: "Together with five Soviet avant-garde artists, hero of the Russian revolution Polina Schneider travels to Siberia to 'civilize' the native Khanty and Nenets tribes, for whom interaction ...",
title: 'Angels of Revolution',
year: 2014
},
{
plot: 'Two mismatched sets of identical twins - one aristocrat, one peasant - mistakenly exchange identities on the eve of the French Revolution.',
title: 'Start the Revolution Without Me',
year: 1970
},
{
plot: "A history of the French Revolution from the decision of the king to convene the Etats-Generaux in 1789 in order to deal with France's debt problem. The first part of the movie tells the ...",
title: 'La rèvolution franèaise',
year: 1989
}
]

결과의 문서에는 titleplot 필드 모두에 쿼리 텀이 포함되어 있습니다. 각 분석기는 결과의 각 문서의 title 필드에 대해 다음 토큰(검색 가능한 텀)을 생성합니다.

분석기

Index Tokens

쿼리 토큰

2012

Standard Analyzer
French Analyzer
revolution
revolution
revolution
revolution

1985

Standard Analyzer
French Analyzer
revolution
revolution
revolution
revolution

2014

Standard Analyzer
French Analyzer
angels, of, revolution
angels, of, revolution
revolution
revolution

1970

Standard Analyzer
French Analyzer
start, the, revolution, without, me
start, the, revolution, without
revolution
revolution

1989

Standard Analyzer
French Analyzer
la, rèvolution, franèaise
revolution, franeais
revolution
revolution

결과의 다섯 번째 문서에서 frenchAnalyzertitle 필드의 발음 구별 기호를 제거하여 쿼리 텀과 일치하는 문서를 찾습니다.

돌아가기

Language