mirror of
https://github.com/typeable/bloodhound.git
synced 2024-09-11 08:25:32 +03:00
Added a constructor to denote "auto" fuzziness to the Fuzziness type
This commit is contained in:
parent
4e61602b3f
commit
52b67cdbdf
@ -110,8 +110,6 @@ newtype MinimumTermFrequency =
|
||||
MinimumTermFrequency Int deriving (Eq, Show, FromJSON, ToJSON)
|
||||
newtype MaxQueryTerms =
|
||||
MaxQueryTerms Int deriving (Eq, Show, FromJSON, ToJSON)
|
||||
newtype Fuzziness =
|
||||
Fuzziness Double deriving (Eq, Show, FromJSON, ToJSON)
|
||||
|
||||
{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
|
||||
newtype PrefixLength =
|
||||
|
@ -1624,3 +1624,16 @@ fieldTagged :: Monad m => (FieldName -> Object -> m a) -> Object -> m a
|
||||
fieldTagged f o = case HM.toList o of
|
||||
[(k, Object o')] -> f (FieldName k) o'
|
||||
_ -> fail "Expected object with 1 field-named key"
|
||||
|
||||
{-| Fuzziness value as a number or 'AUTO'. -}
|
||||
data Fuzziness = Fuzziness Double | FuzzinessAuto
|
||||
deriving (Eq, Show)
|
||||
|
||||
instance ToJSON Fuzziness where
|
||||
toJSON (Fuzziness n) = toJSON n
|
||||
toJSON FuzzinessAuto = String "AUTO"
|
||||
|
||||
instance FromJSON Fuzziness where
|
||||
parseJSON (String "AUTO") = return FuzzinessAuto
|
||||
parseJSON (String "auto") = return FuzzinessAuto
|
||||
parseJSON v = Fuzziness <$> parseJSON v
|
||||
|
Loading…
Reference in New Issue
Block a user