Docs Menu
Docs Home
/
Atlas
/ / / /

簡易アナライザ

simpleアナライザは、空白、句読点、1 桁以上の数字など、文字以外の文字を見つけた場合、テキストを検索可能なターム(トークン)に分割します。 すべてのテキストを小文字に変換します。

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 バイトを超える、string フィールドのインデックスません。キーワードアナライザを使用している場合、32766 バイトを超える string フィールドはインデックス化されません。

次のインデックス定義の例では、 アナライザを使用して、 titlesample_mflix.moviesコレクションの フィールドのインデックスを指定します。この例に従うには、クラスターにサンプルデータをロードし、simple を使用するか、 mongoshCreate a Search IndexMongoDB Search インデックスの作成 チュートリアルの手順に従って Atlas UIの ページに移動します。

次に、movies コレクションをデータソースとして使用し、 または Atlasmongosh UIVisual 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] を選択します。

    searchAnalyzer

    ドロップダウンから [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

MongoDB Search では、simpleアナライザがクエリタームのlion に一致する lion 用の別のトークンが作成されているため、結果にドキュメントLion's Den が返されます。対照的に、 標準 アナライザ または ホワイトスペース アナライザ を使用してフィールドをインデックスと、 MongoDB Search はクエリの結果に一部のドキュメントを返しますが、Lion's Den は結果として返されません。これらのアナライザはlion's Lion'slion のトークンを作成するためです。それぞれを使用しますが、 のトークンは作成しません。

戻る

標準