def testJson(self):
     response = LuceneResponse(total=3, hits=['1','2','3'])
     response.drilldownData = [{'terms':[], 'fieldname':'field'}]
     response2 = LuceneResponse.fromJson(response.asJson())
     self.assertEquals(3, response2.total)
     self.assertEquals(['1','2','3'], response2.hits)
     self.assertEquals([{'terms':[], 'fieldname':'field'}], response2.drilldownData)
예제 #2
0
 def testJson(self):
     response = LuceneResponse(total=3, hits=['1', '2', '3'])
     response.drilldownData = [{'terms': [], 'fieldname': 'field'}]
     response2 = LuceneResponse.fromJson(response.asJson())
     self.assertEquals(3, response2.total)
     self.assertEquals(['1', '2', '3'], response2.hits)
     self.assertEquals([{
         'terms': [],
         'fieldname': 'field'
     }], response2.drilldownData)
예제 #3
0
def luceneResponseFromDict(responseDict):
    hits = [Hit(**hit) for hit in responseDict['hits']]
    response = LuceneResponse(total=responseDict["total"], queryTime=responseDict["queryTime"], hits=hits, drilldownData=[])
    if "totalWithDuplicates" in responseDict:
        response.totalWithDuplicates = responseDict['totalWithDuplicates']
    if "drilldownData" in responseDict:
        response.drilldownData = responseDict['drilldownData']
    if "suggestions" in responseDict:
        response.suggestions = responseDict['suggestions']
    if "times" in responseDict:
        response.times = responseDict['times']
    return response