git.iko.soy/typeable/bloodhound
on master help sign in
Added a constructor to denote "auto" fuzziness to the Fuzziness type
commit52b67cdbdf1b158392382096c822f28c8be025c1 authorAshutosh Rishi Ranjan <ashutoshrishi92@gmail.com> dateTue 19 Jun 2018, 18:21 (8 years ago) parent4e61602
2 files changed+13−2
src/Database/V5/Bloodhound/Internal/Newtypes.hs−2 src/Database/V5/Bloodhound/Internal/Query.hs+13
src/Database/V5/Bloodhound/Internal/Newtypes.hs−2
@@ -110,8 +110,6 @@ newtype MinimumTermFrequency =
110110 MinimumTermFrequency Int deriving (Eq, Show, FromJSON, ToJSON)
111111newtype MaxQueryTerms =
112112 MaxQueryTerms Int deriving (Eq, Show, FromJSON, ToJSON)
113−newtype Fuzziness =
114− Fuzziness Double deriving (Eq, Show, FromJSON, ToJSON)
115113
116114{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
117115newtype PrefixLength =
src/Database/V5/Bloodhound/Internal/Query.hs+13
@@ -1624,3 +1624,16 @@ fieldTagged :: Monad m => (FieldName -> Object -> m a) -> Object -> m a
16241624fieldTagged f o = case HM.toList o of
16251625 [(k, Object o')] -> f (FieldName k) o'
16261626 _ -> fail "Expected object with 1 field-named key"
1627+
1628+{-| Fuzziness value as a number or 'AUTO'. -}
1629+data Fuzziness = Fuzziness Double | FuzzinessAuto
1630+ deriving (Eq, Show)
1631+
1632+instance ToJSON Fuzziness where
1633+ toJSON (Fuzziness n) = toJSON n
1634+ toJSON FuzzinessAuto = String "AUTO"
1635+
1636+instance FromJSON Fuzziness where
1637+ parseJSON (String "AUTO") = return FuzzinessAuto
1638+ parseJSON (String "auto") = return FuzzinessAuto
1639+ parseJSON v = Fuzziness <$> parseJSON v