git.iko.soy/typeable/bloodhound
on master help sign in
Added a constructor to denote "auto" fuzziness to the Fuzziness type
52b67cdAshutosh Rishi Ranjan
src/Database/V5/Bloodhound/Internal/Newtypes.hs−2
@@ -110,8 +110,6 @@ newtype MinimumTermFrequency =
110 MinimumTermFrequency Int deriving (Eq, Show, FromJSON, ToJSON)
110 MinimumTermFrequency Int deriving (Eq, Show, FromJSON, ToJSON)
111newtype MaxQueryTerms =
111newtype MaxQueryTerms =
112 MaxQueryTerms Int deriving (Eq, Show, FromJSON, ToJSON)
112 MaxQueryTerms Int deriving (Eq, Show, FromJSON, ToJSON)
113−newtype Fuzziness =
114− Fuzziness Double deriving (Eq, Show, FromJSON, ToJSON)
115
113
116{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
114{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
117newtype PrefixLength =
115newtype PrefixLength =
src/Database/V5/Bloodhound/Internal/Query.hs+13
@@ -1624,3 +1624,16 @@ fieldTagged :: Monad m => (FieldName -> Object -> m a) -> Object -> m a
1624fieldTagged f o = case HM.toList o of
1624fieldTagged f o = case HM.toList o of
1625 [(k, Object o')] -> f (FieldName k) o'
1625 [(k, Object o')] -> f (FieldName k) o'
1626 _ -> fail "Expected object with 1 field-named key"
1626 _ -> 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