git.iko.soy/typeable/bloodhound
on master help sign in
Added Fuzziness to MatchQuery
4e61602Ashutosh Rishi Ranjan
src/Database/V5/Bloodhound/Internal/Query.hs+5−2
@@ -845,6 +845,7 @@ data MatchQuery = MatchQuery
845 , matchQueryLenient :: Maybe Lenient
845 , matchQueryLenient :: Maybe Lenient
846 , matchQueryBoost :: Maybe Boost
846 , matchQueryBoost :: Maybe Boost
847 , matchQueryMinimumShouldMatch :: Maybe Text
847 , matchQueryMinimumShouldMatch :: Maybe Text
848+ , matchQueryFuzziness :: Maybe Fuzziness
848 } deriving (Eq, Show)
849 } deriving (Eq, Show)
849
850
850
851
@@ -853,7 +854,7 @@ instance ToJSON MatchQuery where
853 (QueryString mqQueryString) booleanOperator
854 (QueryString mqQueryString) booleanOperator
854 zeroTermsQuery cutoffFrequency matchQueryType
855 zeroTermsQuery cutoffFrequency matchQueryType
855 analyzer maxExpansions lenient boost
856 analyzer maxExpansions lenient boost
856− minShouldMatch
857+ minShouldMatch mqFuzziness
857 ) =
858 ) =
858 object [ fieldName .= omitNulls base ]
859 object [ fieldName .= omitNulls base ]
859 where base = [ "query" .= mqQueryString
860 where base = [ "query" .= mqQueryString
@@ -866,6 +867,7 @@ instance ToJSON MatchQuery where
866 , "lenient" .= lenient
867 , "lenient" .= lenient
867 , "boost" .= boost
868 , "boost" .= boost
868 , "minimum_should_match" .= minShouldMatch
869 , "minimum_should_match" .= minShouldMatch
870+ , "fuzziness" .= mqFuzziness
869 ]
871 ]
870
872
871instance FromJSON MatchQuery where
873instance FromJSON MatchQuery where
@@ -882,12 +884,13 @@ instance FromJSON MatchQuery where
882 <*> o .:? "lenient"
884 <*> o .:? "lenient"
883 <*> o .:? "boost"
885 <*> o .:? "boost"
884 <*> o .:? "minimum_should_match"
886 <*> o .:? "minimum_should_match"
887+ <*> o .:? "fuzziness"
885
888
886{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
889{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
887 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
890 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
888-}
891-}
889mkMatchQuery :: FieldName -> QueryString -> MatchQuery
892mkMatchQuery :: FieldName -> QueryString -> MatchQuery
890−mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing Nothing
893+mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
891
894
892data MatchQueryType =
895data MatchQueryType =
893 MatchPhrase
896 MatchPhrase