2017-06-02 25 views
0

當我指數Solr的以下文件:我如何通過solr/lucene中的字段對片段進行分組?

[ 
    { 
    "id" : "978-0641723445", 
    "name" : "The Lightning Thief", 
    "author" : "Rick Riordan", 
    "series_t" : "Rick Jackson and the Olympians", 
    } 
, 
    { 
    "id" : "978-1423103349", 
    "cat" : ["book","paperback"], 
    "name" : "The Sea of Monsters", 
    "author" : "Rick Riordan", 
    "series_t" : "Rick Jackson and the Olympians", 
    } 
] 

和運行以下查詢: http://localhost:8983/solr/gettingstarted/select?hl.fl=name&hl=on&indent=on&q=rick&rows=20&wt=json

我想有一個包含每個匹配字段的名稱的摘錄和子摘錄該字段的內容(子摘錄的實際格式是不那麼重要):

"responseHeader": { 
    "status": 0, 
    "QTime": 1, 
    "params": { ... 
    }, 
    "response": { 
     "numFound": 2, 
     "start": 0, 
     "docs": [{ 
       "id": "978-0641723445", 
       .. { 
        "id": "978-1423103349", 
        .. 
       }], 
      "highlighting": { 
       "978-0641723445": { 
        "author": "Rick Riordan", 
        "series_t": "Rick Riordan and..." 
       }, 
       "978-1423103349": { 
        "author": "Rick Riordan", 
        "series_t": "Rick Riordan and..." 

       } 
      } 
     } 
    } 

怎麼辦我必須改變我的Solr查詢做到這一點?或者這種變化是否需要定製solr/lucene熒光筆?

+0

您是否嘗試過'hl.requireFieldMatch = true'與'hl.fl = *' - 這應該會讓您在查詢匹配的所有字段上突出顯示。 – MatsLindh

+0

謝謝@MatsLindh,這個解決方案適合我! – layoutanalysis

回答

相關問題