Overview
MongoDB検索するアナライザは、文字のシーケンスを変換、フィルター、グループ化するための一連の操作を実行して、インデックスを作成するドキュメントのセットを準備します。Atlas UIから、特定のインデックスの作成ニーズに合わせてカスタムアナライザを定義できます。
A custom MongoDB Search analyzer is made up of a tokenizer, an optional list of character filters, and an optional list of token filters. When MongoDB Search analyzes text with a custom analyzer, the text passes through the character filters first, then the tokenizer, and then the token filters.
構文
カスタムアナライザの構文は次のとおりです。
"analyzers": [ { "name": "<name>", "charFilters": [ <list-of-character-filters> ], "tokenizer": { "type": "<tokenizer-type>" }, "tokenFilters": [ <list-of-token-filters> ] } ]
属性
カスタムアナライザには、次の属性があります。
属性 | タイプ | 説明 | 必須 |
|---|---|---|---|
| string | カスタムアナライザの名前。 名前はインデックス内で一意である必要があり、次のいずれかの文字列で始まらない必要があります。
| はい |
| オブジェクトのリスト | no | |
| オブジェクト | トークンを作成するために使用するトークナイザ。 アナライザは、インデックスを作成する目的で、トークナイザを使用してテキストのかたまりをグループまたはトークンに分裂します。 詳細については、「トークナイザ」を参照してください。 | はい |
| オブジェクトのリスト | 0 個以上のトークン フィルターを含む配列。 トークン フィルターは、以下のような処理を実行します。
To learn more, see Token Filters for Custom Analyzers. | no |
組み込みカスタムアナライザテンプレート
The Atlas UI Visual Editor includes the option to choose between the following common-use templates to help you get started with building your custom analyzer:
メール パーサー - uaxUrlEmail トークナイザで最大 200 文字のメールアドレスをトークン化するために使用します。たとえば、このアナライザは、サンプル コレクションの
page_updated_by.emailフィールドに適用できます。電話番号 - regexCaptureGroup トークナイザで米国形式の電話番号から単一トークンを作成するために使用します。たとえば、サンプル コレクションの
page_updated_by.phoneフィールドにこのアナライザを適用できます。ハイフン区切りの ID - regexSplitトークナイザを使用して、ハイフンで区切られたテキストからトークンを作成する際に使用します。たとえば、コレクション例の
messageフィールドにこのアナライザを適用できます。
これらの組み込みカスタムアナライザを使用するか、MongoDB Search Visual Editor または JSON エディターを使用して独自のカスタムアナライザを作成できます。
コレクションの例
The Character Filters, Tokenizers, and Token Filters for Custom Analyzers pages contain sample index definitions and query examples for character filters, tokenizers, and token filters. These examples use a sample minutes collection with the following documents:
{ "_id": 1, "page_updated_by": { "last_name": "AUERBACH", "first_name": "Siân", "email": "auerbach@example.com", "phone": "(123)-456-7890" }, "title": "The team's weekly meeting", "message": "try to siGn-In", "text": { "en_US": "<head> This page deals with department meetings.</head>", "sv_FI": "Den här sidan behandlar avdelningsmöten", "fr_CA": "Cette page traite des réunions de département" } }
{ "_id": 2, "page_updated_by": { "last_name": "OHRBACH", "first_name": "Noël", "email": "ohrbach@example.com", "phone": "(123) 456 0987" }, "title": "The check-in with sales team", "message": "do not forget to SIGN-IN. See ① for details.", "text" : { "en_US": "The head of the sales department spoke first.", "fa_IR": "ابتدا رئیس بخش فروش صحبت کرد", "sv_FI": "Först talade chefen för försäljningsavdelningen" } }
{ "_id": 3, "page_updated_by": { "last_name": "LEWINSKY", "first_name": "Brièle", "email": "lewinsky@example.com", "phone": "(123).456.9870" }, "title": "The regular board meeting", "message": "try to sign-in", "text" : { "en_US": "<body>We'll head out to the conference room by noon.</body>" } }
{ "_id": 4, "page_updated_by": { "last_name": "LEVINSKI", "first_name": "François", "email": "levinski@example.com", "phone": "123-456-8907" }, "title": "The daily huddle on tHe StandUpApp2", "message": "write down your signature or phone №", "text" : { "en_US": "<body>This page has been updated with the items on the agenda.</body>" , "es_MX": "La página ha sido actualizada con los puntos de la agenda.", "pl_PL": "Strona została zaktualizowana o punkty porządku obrad." } }
詳細
独自のカスタムアナライザの作成についての詳細は、以下の参照ページをご覧ください。
注意
Atlas UI でVisual Editorを使用してカスタムアナライザを追加すると、Atlas UI のCustom Analyzersセクションにアナライザに関する次の詳細が表示されます。
名前 | カスタムアナライザを識別するラベル。 |
で使用される | カスタムアナライザを使用するフィールド。 カスタム アナライザ がフィールドを分析するために使用されない場合、値は[なし]です。 |
文字フィルター | |
トークナイザ | |
トークン フィルター | カスタムアナライザで構成されたMongoDB Search トークン フィルター。 |
アクション | カスタム アナライザで実行できるアクションを示すクリック可能なアイコン。
|