git.iko.soy/typeable/bloodhound
on master help sign in
well we might actually be able to parse search results now
d4fe69cChris Allen
Database/Bloodhound/Client.hs+31−5
@@ -97,8 +97,9 @@ mkReplicaCount n
97
97
98-- IndexSettings <$> mkShardCount 10 <*> mkReplicaCount 20
98-- IndexSettings <$> mkShardCount 10 <*> mkReplicaCount 20
99
99
100+data IndexSettings =
100−data IndexSettings = IndexSettings { shards :: ShardCount
101+ IndexSettings { indexShards :: ShardCount
101− , replicas :: ReplicaCount } deriving (Show, Generic)
102+ , indexReplicas :: ReplicaCount } deriving (Show)
102
103
103instance ToJSON IndexSettings where
104instance ToJSON IndexSettings where
104 toJSON (IndexSettings s r) = object ["settings" .= object ["shards" .= s, "replicas" .= r]]
105 toJSON (IndexSettings s r) = object ["settings" .= object ["shards" .= s, "replicas" .= r]]
@@ -356,8 +357,8 @@ data Term = Term { termField :: Text
356 , termValue :: Text } deriving (Show)
357 , termValue :: Text } deriving (Show)
357
358
358instance ToJSON Term where
359instance ToJSON Term where
359− toJSON (Term termField termValue) = object ["term" .= object
360+ toJSON (Term field value) = object ["term" .= object
360− [termField .= termValue]]
361+ [field .= value]]
361
362
362data BoolMatch = MustMatch Term
363data BoolMatch = MustMatch Term
363 | MustNotMatch Term
364 | MustNotMatch Term
@@ -402,7 +403,32 @@ data OptimizeBbox = GeoFilterType | NoOptimizeBbox deriving (Show)
402
403
403data Distance =
404data Distance =
404 Distance { coefficient :: Double
405 Distance { coefficient :: Double
405− , unit :: DistanceUnits } deriving (Show)
406+ , unit :: DistanceUnits } deriving (Show)
407+
408+data FromJSON a => SearchResults a =
409+ SearchResults { took :: Int
410+ , timedOut :: Bool
411+ , shards :: ShardResults
412+ , searchHits :: SearchHits a } deriving (Show)
413+
414+type Score = Double
415+
416+data FromJSON a => SearchHits a =
417+ SearchHits { hitsTotal :: Int
418+ , maxScore :: Score
419+ , hits :: [Hits a] } deriving (Show)
420+
421+data FromJSON a => Hits a =
422+ Hits { hitsIndex :: IndexName
423+ , hitsType :: MappingName
424+ , hitDocumentID :: DocumentID
425+ , hitScore :: Score
426+ , hitSource :: a } deriving (Show)
427+
428+data ShardResults =
429+ ShardResults { shardTotal :: Int
430+ , shardsSuccessful :: Int
431+ , shardsFailed :: Int } deriving (Show)
406
432
407-- This is turning into a fractal of horror
433-- This is turning into a fractal of horror
408-- data Fuzziness = FDateFuzziness DateFuzziness |
434-- data Fuzziness = FDateFuzziness DateFuzziness |