2014-10-03 55 views
1

當使用AWS .NET SDK執行cloudsearch searchrequest時,SearchRequest.Return屬性中指定的表達式不會在字段集合中返回。將以下SearchRequest對象傳遞給AmazonCloudSearchDomainClient實例時,我們會爲距離表達式保存所有字段。我們如何使用SDK訪問每次擊中的表達式?CloudSearch表達式不會使用.net工具包返回

new SearchRequest 
    { 
     QueryParser = QueryParser.Structured, 
      FilterQuery = "location:['BOUNDING BOX COORDINATES','HERE']", 
      Sort = "distance asc", 
      Expr = @"{{""distance"":""haversin(SOME LATITUDE,SOME_LONGITUDE,location.latitude,location.longitude) * .621371""}}", 
      Return = "_all_fields,distance", 
      Query = "(term field=awesome 1)", 
      Start = 0, 
      Size = 50 
    }; 

回答

0

「我們如何使用SDK訪問每次擊中的表達式?」

簡短的回答是,你沒有。 .net sdk有一個缺點,因爲它不返回表達式值。 https://forums.aws.amazon.com/thread.jspa?messageID=575746 希望它很快就會解決,直到那時我們將不得不通過http發出請求並自己解析結果......哦,恐怖。我們只需要將json修改爲具有額外的Expr集合的裝飾的Hit對象,因此當它被修復時,它不會太麻煩,無法返回。