2012-04-18 17 views
2

私は、別のネストされたフィールドを含むネストされたフィールドを持つElasticsearchドキュメントのインデックスを作成しています(フィールドの2ステップツリー)。内部のネストされたフィールドのデータに基づいてドキュメントを照合します。これは機能しません。ネストされたフィルタを使用したElasticSearchクエリは機能しません

NestedFilterBuilderは、これは私がインデックスが構築されているクエリ

orFilter.add(termFilter("event_attribute_value","president")); 
NestedFilterBuilder nestedFilterBuilder = new NestedFilterBuilder("eventnested.attributes", orFilter); 
finalFilter.add(nestedFilterBuilder); 

マッピングが

"eventnested":{ 
      "type" : "nested", "store" : "yes", "index" : "analyzed", "omit_norms" : "true", 
      "include_in_parent":true, 
      "properties":{    
       "event_type":{"type" : "string", "store" : "yes", "index" : "analyzed","omit_norms" : "true"}, 
       "attributes":{ 
       "type" : "nested", "store" : "yes", "index" : "analyzed", "omit_norms" : "true", 
       "include_in_parent":true, 
        "properties":{ 
         "event_attribute_name":{"type" : "string", "store" : "yes", "index" : "analyzed","omit_norms" : "true"}, 
         "event_attribute_value":{"type" : "string", "store" : "yes", "index" : "analyzed","omit_norms" : "true"} 
        } 
        }, 
       "event_attribute_instance":{"type" : "integer", "store" : "yes", "precision_step" : "0"} 
       }           
       } 
で生成するのに使用していたJavaで

 "nested" : { 
      "filter" : { 
      "or" : { 
       "filters" : [ { 
       "term" : { 
        "event_attribute_value" : "Obama" 
       } 
       }, { 
       "term" : { 
        "event_attribute_value" : "President" 
       } 
       } ] 
      } 
      }, 
      "path" : "eventnested.attributes" 
     } 

... 1以下のようになります。

私が間違って使っていることはありますか?

答えて

3

あなたのマッピングevent_attribute_valueによると、分析されます。つまり、「オバマ大統領」の索引付けでは、「大統領」と「オバマ」という2つのトークンに分析されます。あなたは、インデックスに存在しないトークン "President"と "Obama"を検索しています。

あなたは「あなたの用語フィルタで正しいトークン(「社長」を使用してテキストクエリまたは

  • と用語フィルターを交換
  • not_analyzedにフィールドマッピングを変更

    1. することにより、この問題を解決することができオバマ "の場合は )。
  • +0

    ありがとうございました。私は、フィールドnot_analyzedをqueryfilterbuilderの使用と共に作成しました。 – Manoj

    関連する問題