Azure Cognitive Search インデックスの文字列フィールドに言語アナライザーを追加するAdd language analyzers to string fields in an Azure Cognitive Search index
"言語アナライザー" は、テキスト アナライザーの固有の種類であり、対象言語の言語規則を使用して字句解析を実行します。A language analyzer is a specific type of text analyzer that performs lexical analysis using the linguistic rules of the target language. すべての検索可能フィールドには、analyzer プロパティがあります。Every searchable field has an analyzer property. 翻訳された文字列でコンテンツが構成されている場合 (英語と中国語のテキストが別のフィールドの場合など)、各フィールドで言語アナライザーを指定して、これらのアナライザーの豊富な言語機能にアクセスできます。If your content consists of translated strings, such as separate fields for English and Chinese text, you could specify language analyzers on each field to access the rich linguistic capabilities of those analyzers.
言語アナライザーを使用する場合When to use a language analyzer
単語または文の構造を認識することでテキスト解析の価値が高まる場合は、言語アナライザーを検討してください。You should consider a language analyzer when awareness of word or sentence structure adds value to text parsing. 一般的な例としては、不規則な動詞の形 ("bring" と "brought") や複数名詞 ("mice" と mouse") の関連付けなどがあります。A common example is the association of irregular verb forms ("bring" and "brought) or plural nouns ("mice" and "mouse"). 言語認識なしでは、これらの文字列は物理的な特性だけで解析され、つながりを見つけることができません。Without linguistic awareness, these strings are parsed on physical characteristics alone, which fails to catch the connection. テキストの大部分にはこのコンテンツが含まれる可能性が高いため、説明、レビュー、または要約で構成されるフィールドは、言語アナライザーの候補として適しています。Since large chunks of text are more likely to have this content, fields consisting of descriptions, reviews, or summaries are good candidates for a language analyzer.
また、コンテンツが西洋以外の言語の文字列で構成されている場合も、言語アナライザーを検討してください。You should also consider language analyzers when content consists of non-Western language strings. 既定のアナライザーは言語に依存しませんが、スペースと特殊文字 (ハイフンとスラッシュ) を使用して文字列を区切るという概念は、西洋以外の言語よりも西洋言語に当てはまる傾向があります。While the default analyzer is language-agnostic, the concept of using spaces and special characters (hyphens and slashes) to separate strings tends is more applicable to Western languages than non-Western ones.
たとえば、中国語、日本語、韓国語 (CJK)、およびその他のアジア言語では、スペースは必ずしも単語の区切り記号ではありません。For example, in Chinese, Japanese, Korean (CJK), and other Asian languages, a space is not necessarily a word delimiter. 次の日本語の文字列を考えてみます。Consider the following Japanese string. これにはスペースがないため、文字列は実際には句であっても、言語に依存しないアナライザーでは文字列全体が 1 つのトークンとして分析される可能性があります。Because it has no spaces, a language-agnostic analyzer would likely analyze the entire string as one token, when in fact the string is actually a phrase.
これは私たちの銀河系の中ではもっとも重く明るいクラスの球状星団です。
(This is the heaviest and brightest group of spherical stars in our galaxy.)
上記の例では、クエリを正常に実行するには、完全なトークン、またはサフィックス ワイルドカードを使用する部分トークンを含める必要があります。これにより、自然ではない制限的な検索エクスペリエンスが実現します。For the example above, a successful query would have to include the full token, or a partial token using a suffix wildcard, resulting in an unnatural and limiting search experience.
エクスペリエンスを向上させるには、個々の単語を検索することです: 明るい (Bright)、私たちの (Our)、銀河系 (Galaxy)。A better experience is to search for individual words: 明るい (Bright), 私たちの (Our), 銀河系 (Galaxy). Cognitive Search で利用できる日本語アナライザーのいずれかを使用すると、この動作が解除される可能性が高くなります。これらのアナライザーの方が、テキストのチャンクをターゲット言語で意味のある単語に分割することにおいて、より適した機能を備えているためです。Using one of the Japanese analyzers available in Cognitive Search is more likely to unlock this behavior because those analyzers are better equipped at splitting the chunk of text into meaningful words in the target language.
Lucene と Microsoft のアナライザーの比較Comparing Lucene and Microsoft Analyzers
Azure Cognitive Search では、Lucene によって提供される 35 個の言語アナライザーと、Office および Bing で使用される Microsoft 独自の自然言語処理技術によって提供される 50 個の言語アナライザーがサポートされています。Azure Cognitive Search supports 35 language analyzers backed by Lucene, and 50 language analyzers backed by proprietary Microsoft natural language processing technology used in Office and Bing.
開発者によっては、使い慣れた簡単なオープン ソース ソリューションである Lucene を好む場合があります。Some developers might prefer the more familiar, simple, open-source solution of Lucene. Lucene の言語アナライザーは高速です。しかし、マイクロソフトのアナライザーには高度な機能があります。たとえば、レンマ化、単語複混合化 (ドイツ語、デンマーク語、オランダ語、スウェーデン語、ノルウェー語、エストニア語、フィンランド語、ハンガリー語、スロバキア語などの言語で)、エンティティ認識 (URL、電子メール、日付、数値) などです。Lucene language analyzers are faster, but the Microsoft analyzers have advanced capabilities, such as lemmatization, word decompounding (in languages like German, Danish, Dutch, Swedish, Norwegian, Estonian, Finish, Hungarian, Slovak) and entity recognition (URLs, emails, dates, numbers). 可能であれば、マイクロソフトと Lucene の両方のアナライザーを比較し、より適したものを選んでください。If possible, you should run comparisons of both the Microsoft and Lucene analyzers to decide which one is a better fit.
言語によっては、マイクロソフトのアナライザーでのインデックス作成には、平均して、Lucene の同等機能の 2 ~ 3 倍の時間がかかります。Indexing with Microsoft analyzers is on average two to three times slower than their Lucene equivalents, depending on the language. 平均的なサイズのクエリの場合、検索のパフォーマンスはさほど影響はありません。Search performance should not be significantly affected for average size queries.
英語のアナライザーEnglish analyzers
既定のアナライザーは標準 Lucene であり、英語でも問題なく動作しますが、おそらく Lucene の英語アナライザーや Microsoft の英語アナライザーほどではありません。The default analyzer is Standard Lucene, which works well for English, but perhaps not as well as Lucene's English analyzer or Microsoft's English analyzer.
Lucene の英語アナライザーでは、標準アナライザーが拡張されています。Lucene's English analyzer extends the Standard analyzer. 単語から所有格 (末尾の 's) が除去され、Porter Stemming アルゴリズムに従ってステミングが適用され、英語のストップワードが除去されます。It removes possessives (trailing 's) from words, applies stemming as per Porter Stemming algorithm, and removes English stop words.
Microsoft の英語アナライザーでは、ステミングではなくレンマ化が実行されます。Microsoft's English analyzer performs lemmatization instead of stemming. つまり、語形変化および変則的な語形がより適切に処理され、関連性の高い検索結果が得られますThis means it can handle inflected and irregular word forms much better which results in more relevant search results
言語アナライザーを指定する方法How to specify a language analyzer
フィールド定義時に、Edm.String 型の "検索可能な" フィールドで言語アナライザーを設定します。Set a language analyzer on "searchable" fields of type Edm.String during field definition.
フィールド定義にはアナライザー関連のプロパティが複数ありますが、言語アナライザーに使用できるのは "analyzer" プロパティだけです。Although field definitions have several analyzer-related properties, only the "analyzer" property can be used for language analyzers. "analyzer" の値は、サポート アナライザーの一覧にある言語アナライザーのいずれかである必要があります。The value of "analyzer" must be one of the language analyzers from the support analyzers list.
{
"name": "hotels-sample-index",
"fields": [
{
"name": "Description",
"type": "Edm.String",
"retrievable": true,
"searchable": true,
"analyzer": "en.microsoft",
"indexAnalyzer": null,
"searchAnalyzer": null
},
{
"name": "Description_fr",
"type": "Edm.String",
"retrievable": true,
"searchable": true,
"analyzer": "fr.microsoft",
"indexAnalyzer": null,
"searchAnalyzer": null
},
インデックスの作成とフィールド プロパティの設定の詳細については、Create Index (REST) に関するページを参照してください。For more information about creating an index and setting field properties, see Create Index (REST). テキストの解析について詳しくは、Azure Cognitive Search でのアナライザーに関する記事をご覧ください。For more information about text analysis, see Analyzers in Azure Cognitive Search.
サポートされる言語アナライザーSupported language analyzers
サポートされている言語と、Lucene およびマイクロソフトのアナライザーの名前を以下に一覧します。Below is the list of supported languages, with Lucene and Microsoft analyzer names.
LanguageLanguage | Microsoft のアナライザーの名前Microsoft Analyzer Name | Lucene のアナライザーの名前Lucene Analyzer Name |
---|---|---|
アラビア語Arabic | ar.microsoftar.microsoft | ar.lucenear.lucene |
アルメニア語Armenian | hy.lucenehy.lucene | |
ベンガル語Bangla | bn.microsoftbn.microsoft | |
バスク語Basque | eu.luceneeu.lucene | |
ブルガリア語Bulgarian | bg.microsoftbg.microsoft | bg.lucenebg.lucene |
カタロニア語Catalan | ca.microsoftca.microsoft | ca.luceneca.lucene |
簡体中国語Chinese Simplified | zh-Hans.microsoftzh-Hans.microsoft | zh-Hans.lucenezh-Hans.lucene |
中国語 (繁体字)Chinese Traditional | zh-Hant.microsoftzh-Hant.microsoft | zh-Hant.lucenezh-Hant.lucene |
クロアチア語Croatian | hr.microsofthr.microsoft | |
チェコ語Czech | cs.microsoftcs.microsoft | cs.lucenecs.lucene |
デンマーク語Danish | da.microsoftda.microsoft | da.luceneda.lucene |
オランダ語Dutch | nl.microsoftnl.microsoft | nl.lucenenl.lucene |
英語English | en.microsoften.microsoft | en.luceneen.lucene |
エストニア語Estonian | et.microsoftet.microsoft | |
フィンランド語Finnish | fi.microsoftfi.microsoft | fi.lucenefi.lucene |
フランス語French | fr.microsoftfr.microsoft | fr.lucenefr.lucene |
ガリシア語Galician | gl.lucenegl.lucene | |
ドイツ語German | de.microsoftde.microsoft | de.lucenede.lucene |
ギリシャ語Greek | el.microsoftel.microsoft | el.luceneel.lucene |
グジャラート語Gujarati | gu.microsoftgu.microsoft | |
ヘブライ語Hebrew | he.microsofthe.microsoft | |
ヒンディー語Hindi | hi.microsofthi.microsoft | hi.lucenehi.lucene |
ハンガリー語Hungarian | hu.microsofthu.microsoft | hu.lucenehu.lucene |
アイスランド語Icelandic | is.microsoftis.microsoft | |
インドネシア語Indonesian (Bahasa) | id.microsoftid.microsoft | id.luceneid.lucene |
アイルランド語Irish | ga.lucenega.lucene | |
イタリア語Italian | it.microsoftit.microsoft | it.luceneit.lucene |
日本語Japanese | ja.microsoftja.microsoft | ja.luceneja.lucene |
カンナダ語Kannada | kn.microsoftkn.microsoft | |
韓国語Korean | ko.microsoftko.microsoft | ko.luceneko.lucene |
ラトビア語Latvian | lv.microsoftlv.microsoft | lv.lucenelv.lucene |
リトアニア語Lithuanian | lt.microsoftlt.microsoft | |
マラヤーラム語Malayalam | ml.microsoftml.microsoft | |
マレー語 (ラテン)Malay (Latin) | ms.microsoftms.microsoft | |
マラーティー語Marathi | mr.microsoftmr.microsoft | |
ノルウェー語Norwegian | nb.microsoftnb.microsoft | no.luceneno.lucene |
ペルシャ語Persian | fa.lucenefa.lucene | |
ポーランド語Polish | pl.microsoftpl.microsoft | pl.lucenepl.lucene |
ポルトガル語 (ブラジル)Portuguese (Brazil) | pt-Br.microsoftpt-Br.microsoft | pt-Br.lucenept-Br.lucene |
ポルトガル語 (ポルトガル)Portuguese (Portugal) | pt-Pt.microsoftpt-Pt.microsoft | pt-Pt.lucenept-Pt.lucene |
パンジャーブ語Punjabi | pa.microsoftpa.microsoft | |
ルーマニア語Romanian | ro.microsoftro.microsoft | ro.lucenero.lucene |
ロシア語Russian | ru.microsoftru.microsoft | ru.luceneru.lucene |
セルビア語 (キリル)Serbian (Cyrillic) | sr-cyrillic.microsoftsr-cyrillic.microsoft | |
セルビア語 (ラテン)Serbian (Latin) | sr-latin.microsoftsr-latin.microsoft | |
スロバキア語Slovak | sk.microsoftsk.microsoft | |
スロベニア語Slovenian | sl.microsoftsl.microsoft | |
スペイン語Spanish | es.microsoftes.microsoft | es.lucenees.lucene |
スウェーデン語Swedish | sv.microsoftsv.microsoft | sv.lucenesv.lucene |
タミル語Tamil | ta.microsoftta.microsoft | |
テルグ語Telugu | te.microsoftte.microsoft | |
タイ語Thai | th.microsoftth.microsoft | th.luceneth.lucene |
トルコ語Turkish | tr.microsofttr.microsoft | tr.lucenetr.lucene |
ウクライナ語Ukrainian | uk.microsoftuk.microsoft | |
ウルドゥ語Urdu | ur.microsoftur.microsoft | |
ベトナム語Vietnamese | vi.microsoftvi.microsoft |
名前に Lucene が含まれるすべてのアナライザーでは、Apache Lucene の言語アナライザーが利用されています。All analyzers with names annotated with Lucene are powered by Apache Lucene's language analyzers.