2016-08-11 8 views
3

動作しない私のコードです:はハイライトを追加することは、私がhasChildQueryを使用すると、すべては私が<code>addHighlightedField()</code>メソッドを追加するとき、それは次のようwork.TheしないOK.But作品Elasticsearch 2.3.3にhas_childクエリで

TermsLookupQueryBuilder terms = QueryBuilders.termsLookupQuery("uuid") 
       .lookupIndex("bropen_framework_core_security_user").lookupType("user").lookupId("5") 
       .lookupPath("uuids"); 


HasChildQueryBuilder bookNameQuery = QueryBuilders.hasChildQuery("process", 
       QueryBuilders.hasChildQuery("permission", terms)); 


SearchResponse searchResponse1 = client 
       .prepareSearch() 
       //.addHighlightedField("_all") 
       .setQuery(hasChildQuery) 
       .setPostFilter(QueryBuilders 
           .queryStringQuery(query.toString())) 
       .setFrom(0) 
       .setSize(1000) 
       .execute().actionGet(); 

例外情報:

RemoteTransportException[[node-224][192.168.0.224:9300] [indices:data/read/search[phase/fetch/id]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight 
field [_all]]]; 
nested: IllegalStateException[can't load global ordinals for 
reader of type: class 
org.apache.lucene.search.highlight.WeightedSpanTermExtractor 
$DelegatingLeafReader must be a DirectoryReader]; 

私はそれを達成するためにどのように、すべてのフィールドを強調表示したい

答えて

2

これは、ここでのgit issueで指定されたバグに関連しているのですか? 。 スレッドで述べたように回避策はhighlight_query

例でそれを指定することです:

PUT test 
{ 
    "mappings": { 
     "my_parent": { 
     "_all": { 
      "store": true 
     } 
     }, 
     "my_child": { 
     "_parent": { 
      "type": "my_parent" 
     } 
     } 
    } 
} 

PUT test/my_parent/1 
{ 
    "text": "This is a parent document" 
} 

PUT test/my_child/2?parent=1 
{ 
    "text": "This is a child document" 
} 

POST test/my_parent/_search 
{ 
    "query": { 
     "bool": { 
     "must": [ 
      { 
       "has_child": { 
        "type": "my_child", 
        "query": { 
        "match": { 
         "text": "child document" 
        } 
        } 
       } 
      }, 
      { 
       "match": { 
        "_all": "parent" 
       } 
      } 
     ] 
     } 
    }, 
    "highlight": { 
     "fields": { 
     "_all": {} 
     }, 
     "highlight_query": { 
     "match": { 
      "_all": "parent" 
     } 
     } 
    } 
} 

結果:Javaクライアントで

{ 
      "_index": "test", 
      "_type": "my_parent", 
      "_id": "1", 
      "_score": 1.016466, 
      "_source": { 
       "text": "This is a parent document" 
      }, 
      "highlight": { 
       "_all": [ 
        "This is a <em>parent</em> document " 
       ] 
      } 
     } 

あなたはこのapi

を経由して、それを達成することができるはずです
関連する問題