2016-10-28 8 views
0

私は現在弾性検索を使用しており、いくつかのタイプのクエリを持っています。その中でmatch_phraseクエリを使用しています。これを使用しているインデックスは、テキストメッセージ用の英語解析ツールを使用しています。フレーズを検索すると正確な結果が期待できますが、検索語に英語のような単語が含まれている場合は、「削除」、「削除」、「削除」などの単語もマークされます。English AnalyzerでElasticSearchを検索するフレーズ

フレーズマッチングでこれを防止するにはどうすればよいですか?このようなクエリに対してmatch_phrase以外のより良いオプションがありますか?

アナライザーを交換しなくても可能ですか?以下は、私のクエリは、(それが他のことを行うことができるように構造化)である:

query: { 
    fields : ['_id', 'ownerId'], 
    from: 0, 
    size: 20, 
    query: { 
     filtered: { 
      filter: { 
       and: [group ids] 
      }, 
      query: { 
       bool: { 
        must: { 
         match_phrase: { 
           text: "remove" 
         } 
        } 
        } 
      } 
     } 
    } 
} 

そして、ここでは私のインデックスです:

[MappingTypes.MESSAGE]: { 
    properties: { 
     text: { 
     type: 'string', 
     index: 'analyzed', 
     analyzer: 'english', 
     term_vector: 'with_positions_offsets' 
     }, 
     ownerId: { 
     type: 'string', 
     index: 'not_analyzed', 
     store: true 
     }, 
     groupId: { 
     type: 'string', 
     index: 'not_analyzed', 
     store: true 
     }, 
     itemId: { 
     type: 'string', 
     index: 'not_analyzed', 
     store: true 
     }, 
     createdAt: { 
     type: 'date' 
     }, 
     editedAt: { 
     type: 'date' 
     }, 
     type: { 
     type: 'string', 
     index: 'not_analyzed' 
     } 
    } 
    } 
+0

なぜ英語のアナライザーを削除できないのですか? – ChintanShah25

+0

クエリーだけで使用されているアナライザーを制御することはできますか?私はキーワードに 'アナライザ'を設定するようなことをしようとしますが、失敗するだけです。また、私はES 1.5も使用しています。 –

+0

私はキーワードを使用することができましたが、実際にはこれを行うにはデータをキーワードとして索引付けする必要がありますか?それが立てば、結果は得られません。 –

答えて

1

あなたはさまざまな方法でフィールドを使用するmulti-fieldsを使用することができます(完全一致のための1 1つは部分一致など)。

デフォルトのアナライザであるstandard analyzerでステミングを取り除くことができます。あなたはtext

に戻すことができマッピングにあなたがtext.standardを使用する必要があるとあなたが語幹実行する場合(削除削除しにマッチしたい)完全一致をいつでもその後

POST test_index 
{ 
    "mappings": { 
    "test_type": { 
     "properties": { 
     "text": { 
      "type": "string", 
      "index": "analyzed", 
      "analyzer": "english", 
      "term_vector": "with_positions_offsets", 
      "fields": { 
      "standard": { 
       "type": "string" 
      } 
      } 
     }, 
     "ownerId": { 
      "type": "string", 
      "index": "not_analyzed", 
      "store": true 
     }, 
     "groupId": { 
      "type": "string", 
      "index": "not_analyzed", 
      "store": true 
     }, 
     "itemId": { 
      "type": "string", 
      "index": "not_analyzed", 
      "store": true 
     }, 
     "createdAt": { 
      "type": "date" 
     }, 
     "editedAt": { 
      "type": "date" 
     }, 
     "type": { 
      "type": "string", 
      "index": "not_analyzed" 
     } 
     } 
    } 
    } 
} 

と次のようにあなたのインデックスを作成することができます現在のマッピングを更新することもできますが、どちらの場合もインデックスを再索引付けする必要があります。

PUT test_index/_mapping/test_type 
{ 
    "properties": { 
    "text": { 
     "type": "string", 
     "index": "analyzed", 
     "analyzer": "english", 
     "term_vector": "with_positions_offsets", 
     "fields": { 
     "standard": { 
      "type": "string" 
     } 
     } 
    } 
    } 
} 

これは役に立ちますか?

関連する問題