Docs Menu
Docs Home
/
Atlas
/ / / /

단순 분석기

simple 분석기는 공백, 구두점 또는 하나 이상의 숫자와 같은 문자가 아닌 문자가 발견될 때마다 텍스트를 검색 가능한 텀(토큰)로 나눕니다. 모든 텍스트를 소문자로 변환합니다.

Refine Your Index을 선택하면 Atlas UI Index Configurations 섹션 내에 View text analysis of your selected index configuration 라는 제목의 섹션이 표시됩니다. 이 섹션을 확장하면 Atlas UI simple 분석기 각 샘플 문자열에 대해 생성하는 인덱스 및 검색 토큰이 표시됩니다. Atlas UI Visual Editor에서 인덱스 생성하거나 편집할 때 simple 분석기 내장 샘플 문서 및 쿼리 문자열에 대해 생성하는 토큰을 볼 수 있습니다.

중요

MongoDB Search는 분석기 토큰 크기가 32766 바이트를 초과하는 문자열 필드를 인덱스 하지 않습니다. 키워드 분석기 사용하는 경우 32766 바이트를 초과하는 문자열 필드는 인덱싱되지 않습니다.

다음 예시 인덱스 정의는 분석기 title 사용하여sample_mflix.movies 컬렉션 의 필드 에 대한 simple 인덱스 지정합니다. 이 예시 따라 진행하려면 클러스터에 샘플 데이터를 mongosh 로드하고 Create a Search Index 를 사용하거나 MongoDB 검색 인덱스 만들기 튜토리얼의 단계에 따라 Atlas UI 의 페이지로 이동합니다.

그런 다음 movies 컬렉션 데이터 소스로 사용하여 예시 절차에 따라 mongosh 또는 Atlas UI Visual Editor 또는 JSON editor에서 인덱스 생성합니다.


언어 선택 드롭다운 메뉴를 사용하여 이 페이지의 예시에 대한 인터페이스를 설정하다.


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

  2. Index Configurations 섹션에서 Dynamic Mappingoff로 전환합니다.

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

  4. Customized Configuration를 클릭합니다.

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

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

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

    인덱스 분석기

    드롭다운 메뉴에서 lucene.simple 을(를) 선택합니다.

    검색 분석기

    드롭다운 메뉴에서 lucene.simple 을(를) 선택합니다.

    인덱스 옵션

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

    Store

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

    위 내용 무시

    기본 설정을 유지합니다.

    규범

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

  8. Add를 클릭합니다.

  9. Save Changes를 클릭합니다.

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

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

    {
    "mappings": {
    "fields": {
    "title": {
    "type": "string",
    "analyzer": "lucene.simple"
    }
    }
    }
    }
  2. Next를 클릭합니다.

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

1db.movies.createSearchIndex(
2 "default",
3 {
4 "mappings": {
5 "fields": {
6 "title": {
7 "type": "string",
8 "analyzer": "lucene.simple"
9 }
10 }
11 }
12 }
13)

다음 쿼리는 title 필드에서 lion 라는 용어를 검색하여 출력을 5개의 결과로 제한합니다.

  1. 인덱스 의 Query 버튼을 클릭합니다.

  2. 쿼리 편집하려면 Edit Query 을(를) 클릭합니다.

  3. 쿼리 줄에서 을 클릭하고 데이터베이스 와 컬렉션 선택합니다.

  4. 기본값 쿼리 다음으로 바꾸고 Find을 클릭합니다.

    [
    {
    "$search": {
    "text": {
    "query": "lion",
    "path": "title"
    }
    }
    }
    ]
    SCORE: 3.9090898036956787 _id: "573a13cbf29313caabd8135d"
    awards: Object
    cast: Array (4)
    countries: Array (1)
    directors: Array (1)
    fullplot: "According to the legend of the Shangaan, white lions are the messenger…"
    genres: Array (2)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-09-02 00:45:38.833000000"
    num_mflix_comments: 2
    plot: "According to the legend of the Shangaan, white lions are the messenger…"
    poster: "https://m.media-amazon.com/images/M/MV5BMTcwMTAyMzg5OV5BMl5BanBnXkFtZT…"
    rated: "PG"
    released: 2010-02-19T00:00:00.000+00:00
    runtime: 88
    title: "White Lion"
    type: "movie"
    writers: Array (3)
    year: 2010
    SCORE: 3.363236427307129 _id: "573a1399f29313caabcee7fc"
    awards: Object
    cast: Array (4)
    countries: Array (1)
    directors: Array (2)
    fullplot: "A young lion Prince is cast out of his pride by his cruel uncle, who c…"
    genres: Array (3)
    imdb: Object
    languages: Array (4)
    lastupdated: "2015-08-31 00:04:32.670000000"
    metacritic: 83
    num_mflix_comments: 132
    plot: "Lion cub and future king Simba searches for his identity. His eagernes…"
    poster: "https://m.media-amazon.com/images/M/MV5BYTYxNGMyZTYtMjE3MS00MzNjLWFjNm…"
    rated: "G"
    released: 1994-06-24T00:00:00.000+00:00
    runtime: 89
    title: "The Lion King"
    tomatoes: Object
    type: "movie"
    writers: Array (29)
    year: 1994
    SCORE: 3.363236427307129 _id: "573a13a9f29313caabd1f600"
    awards: Object
    cast: Array (4)
    countries: Array (2)
    directors: Array (1)
    fullplot: "Timon and Pumbaa start to watch the original Lion King movie, but Timo…"
    genres: Array (3)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-09-14 00:01:14.313000000"
    num_mflix_comments: 0
    plot: "Timon the meerkat and Pumbaa the warthog retell the story of The Lion …"
    poster: "https://m.media-amazon.com/images/M/MV5BYzg2N2Y1ODYtY2QyMi00ZDAyLWE3MT…"
    rated: "G"
    released: 2004-02-10T00:00:00.000+00:00
    runtime: 77
    title: "The Lion King 1 1/2"
    tomatoes: Object
    type: "movie"
    writers: Array (5)
    year: 2004
    SCORE: 3.363236427307129 _id: "573a13abf29313caabd24af6"
    awards: Object
    cast: Array (4)
    countries: Array (2)
    directors: Array (1)
    fullplot: "Timon and Pumbaa start to watch the original Lion King movie, but Timo…"
    genres: Array (3)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-08-31 05:44:38.700000000"
    num_mflix_comments: 0
    plot: "Timon the meerkat and Pumbaa the warthog retell the story of The Lion …"
    poster: "https://m.media-amazon.com/images/M/MV5BYzg2N2Y1ODYtY2QyMi00ZDAyLWE3MT…"
    rated: "G"
    released: 2004-02-10T00:00:00.000+00:00
    runtime: 77
    title: "The Lion King 1 1/2"
    tomatoes: Object
    type: "movie"
    writers: Array (5)
    year: 2004
    SCORE: 2.9511470794677734 _id: "573a1396f29313caabce366e"
    awards: Object
    cast: Array (4)
    countries: Array (2)
    directors: Array (1)
    fullplot: "Christmas 1183--an aging and conniving King Henry II plans a reunion w…"
    genres: Array (2)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-09-17 01:39:32.220000000"
    num_mflix_comments: 0
    plot: "1183 AD: King Henry II's three sons all want to inherit the throne, bu…"
    poster: "https://m.media-amazon.com/images/M/MV5BMTkzNzYyMzA5N15BMl5BanBnXkFtZT…"
    rated: "PG"
    released: 1968-10-30T00:00:00.000+00:00
    runtime: 134
    title: "The Lion in Winter"
    tomatoes: Object
    type: "movie"
    writers: Array (2)
    year: 1968
    SCORE: 2.9511470794677734 _id: "573a13c1f29313caabd63be7"
    awards: Object
    cast: Array (4)
    countries: Array (1)
    directors: Array (1)
    genres: Array (1)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-04-24 02:38:23.767000000"
    num_mflix_comments: 0
    poster: "https://m.media-amazon.com/images/M/MV5BMTg4Mzg4NDk5MF5BMl5BanBnXkFtZT…"
    released: 2009-11-06T00:00:00.000+00:00
    runtime: 92
    title: "Son of a Lion"
    tomatoes: Object
    type: "movie"
    writers: Array (1)
    year: 2007
    SCORE: 2.9511470794677734 _id: "573a13dbf29313caabdaf30d"
    awards: Object
    cast: Array (4)
    countries: Array (2)
    directors: Array (1)
    fullplot: "Neo-Nazi falls in love with a woman who has a black son and finds hims…"
    genres: Array (2)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-08-15 00:13:18.457000000"
    num_mflix_comments: 0
    plot: "Neo-Nazi falls in love with a woman who has a black son and finds hims…"
    poster: "https://m.media-amazon.com/images/M/MV5BY2M4ZjI5NmMtZjcyNy00NWU3LWI2Zj…"
    released: 2013-10-18T00:00:00.000+00:00
    runtime: 104
    title: "Heart of a Lion"
    tomatoes: Object
    type: "movie"
    writers: Array (1)
    year: 2013
    SCORE: 2.629019260406494 _id: "573a1397f29313caabce5e62"
    awards: Object
    cast: Array (4)
    countries: Array (1)
    directors: Array (1)
    fullplot: "At the beginning of the 20th century an American woman is abducted in …"
    genres: Array (3)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-09-02 00:17:16.943000000"
    num_mflix_comments: 2
    plot: "At the beginning of the 20th century an American woman is abducted in …"
    poster: "https://m.media-amazon.com/images/M/MV5BYTNhODI4NWYtYzc1Zi00OGIxLTk5ZW…"
    rated: "PG"
    released: 1975-10-26T00:00:00.000+00:00
    runtime: 119
    title: "The Wind and the Lion"
    tomatoes: Object
    type: "movie"
    writers: Array (1)
    year: 1975
    SCORE: 2.629019260406494 _id: "573a13ebf29313caabdcfc8d"
    awards: Object
    cast: Array (4)
    countries: Array (1)
    directors: Array (1)
    fullplot: "A documentary on young actress, Marianna Palka, as she confronts her r…"
    genres: Array (3)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-09-03 00:37:45.227000000"
    num_mflix_comments: 0
    plot: "A documentary on young actress, Marianna Palka, as she confronts her r…"
    poster: "https://m.media-amazon.com/images/M/MV5BMTgzMTc2OTg2N15BMl5BanBnXkFtZT…"
    released: 2014-01-18T00:00:00.000+00:00
    runtime: 15
    title: "The Lion's Mouth Opens"
    type: "movie"
    writers: Array (1)
    year: 2014
    SCORE: 2.3702940940856934 _id: "573a139af29313caabcf0ccd"
    awards: Object
    cast: Array (4)
    countries: Array (2)
    directors: Array (2)
    fullplot: "Simba and Nala have a daughter, Kiara. Timon and Pumbaa are assigned t…"
    genres: Array (3)
    imdb: Object
    languages: Array (1)
    lastupdated: "2015-08-24 00:49:09.900000000"
    num_mflix_comments: 0
    plot: "Simba's daughter is the key to a resolution of a bitter feud between S…"
    poster: "https://m.media-amazon.com/images/M/MV5BY2Y3MTk2MDgtOTc1Yy00ZmFjLThlNT…"
    rated: "G"
    released: 1998-10-27T00:00:00.000+00:00
    runtime: 81
    title: "The Lion King 2: Simba's Pride"
    tomatoes: Object
    type: "movie"
    writers: Array (10)
    year: 1998
1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "query": "lion",
6 "path": "title"
7 }
8 }
9 },
10 {
11 "$limit": 5
12 },
13 {
14 "$project": {
15 "_id": 0,
16 "title": 1
17 }
18 }
19])
[
{ title: 'White Lion' },
{ title: 'The Lion King' },
{ title: 'The Lion King 1 1/2' },
{ title: 'The Lion King 1 1/2' },
{ title: 'Lion's Den' },
]

MongoDB Search는 lucene.simple 분석기 사용하여 title 필드 의 텍스트에 대해 다음을 수행하여 이러한 문서를 반환합니다.

  • 텍스트를 소문자로 변환합니다.

  • 문자가 아닌 문자가 있는 곳마다 텍스트를 나누어 별도의 토큰을 만듭니다.

다음 표는 MongoDB Search가 단순 분석기 와 대조적으로 결과의 문서에 대해 표준 분석기공백 분석기 를 사용하여 생성하는 토큰을 보여줍니다.

제목
간단한 분석기 토큰
표준 분석기 토큰
공백 분석기 토큰

White Lion

white, lion

white, lion

White, Lion

The Lion King

the, lion, king

the, lion, king

The, Lion, King

The Lion King 1 1/2

the, lion, king

the, lion, king, 1, 1, 2

The, Lion, King, 1, 1/2

Lion's Den

lion, s, den

lion's, den

Lion's, Den

simple 분석기 쿼리 텀 lion와 일치하는 lion에 대해 별도의 토큰을 생성하기 때문에 MongoDB Search는 결과에 Lion's Den 문서 반환합니다. 반면 표준 분석기 또는 공백 분석기를 사용하여 필드 인덱스 경우 MongoDB Search는 Lion's Den 쿼리 결과에서 일부 문서를 반환하지만 lion's Lion's 는 반환하지 lion 않습니다. 이러한 분석기는 및 토큰을 생성하기 때문입니다. 에 대한 토큰을 생성하지 마세요.

돌아가기

스탠다드