2017-04-27 58 views
1

當我使用REST API使用http://localhost:8003/v1/search?q=harry&format=json進行基本搜索時,我從包含harry的所有文檔中得到MarkLogic的結果。從Marklogic搜索有關的所有匹配文件回覆

{ 
    "snippet-format": "snippet", 
    "total": 2, 
    "start": 1, 
    "page-length": 10, 
    "results": [ 
    { 
     "index": 1, 
     "uri": "/store/books/children/c1", 
     "path": "fn:doc(\"/store/books/children/c1\")", 
     "score": 16384, 
     "confidence": 0.5254987, 
     "fitness": 0.6964535, 
     "href": "/v1/documents?uri=%2Fstore%2Fbooks%2Fchildren%2Fc1", 
     "mimetype": "application/xml", 
     "format": "xml", 
     "matches": [ 
     { 
      "path": "fn:doc(\"/store/books/children/c1\")/book/title", 
      "match-text": [ 
      { 
       "highlight": "Harry" 
      }, 
      " Potter" 
      ] 
     } 
     ] 
    }, 
    { 
     "index": 2, 
     "uri": "/store/books/children/c2", 
     "path": "fn:doc(\"/store/books/children/c2\")", 
     "score": 16384, 
     "confidence": 0.5254987, 
     "fitness": 0.6964535, 
     "href": "/v1/documents?uri=%2Fstore%2Fbooks%2Fchildren%2Fc2", 
     "mimetype": "application/xml", 
     "format": "xml", 
     "matches": [ 
     { 
      "path": "fn:doc(\"/store/books/children/c2\")/book/title", 
      "match-text": [ 
      { 
       "highlight": "Harry" 
      }, 
      " Potter Part 1" 
      ] 
     } 
     ] 
    } 
    ], 
    "qtext": "harry", 
    "metrics": { 
    "query-resolution-time": "PT0.0038395S", 
    "snippet-resolution-time": "PT0.001753S", 
    "total-time": "PT0.0068583S" 
    } 
} 

但是我希望響應不僅僅包含文檔的信息,還要返回文檔。這樣我就不必再單獨打電話來獲取文件了。

回答

0

如果multipart/mixed恰好是不是一種選擇(也許是因爲你消耗在瀏覽器的響應),你也可以看看使用<extract-document-data selected="all"/>,可能與合併轉換將XML轉換爲JSON以便處理方便(extractedToJson.sjs就是一個很好的例子)。

請注意,儘管包含實際文檔可能會嚴重拖慢搜索結果的傳輸,特別是在文檔很大的情況下。

HTH!

相關問題