Skip to content

Commit

Permalink
Merge pull request #212 from andrewthad/match_query_minimum_should_match
Browse files Browse the repository at this point in the history
add minimum_should_match to MatchQuery
  • Loading branch information
bitemyapp authored Dec 5, 2017
2 parents 9092939 + f8dd607 commit 07f6bc5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Database/V5/Bloodhound/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,13 +1528,15 @@ data MatchQuery =
, matchQueryAnalyzer :: Maybe Analyzer
, matchQueryMaxExpansions :: Maybe MaxExpansions
, matchQueryLenient :: Maybe Lenient
, matchQueryBoost :: Maybe Boost } deriving (Eq, Read, Show, Generic, Typeable)
, matchQueryBoost :: Maybe Boost
, matchQueryMinimumShouldMatch :: Maybe Text
} deriving (Eq, Read, Show, Generic, Typeable)

{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
-}
mkMatchQuery :: FieldName -> QueryString -> MatchQuery
mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing
mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing Nothing

data MatchQueryType =
MatchPhrase
Expand Down Expand Up @@ -2924,7 +2926,9 @@ instance ToJSON MatchQuery where
toJSON (MatchQuery (FieldName fieldName)
(QueryString mqQueryString) booleanOperator
zeroTermsQuery cutoffFrequency matchQueryType
analyzer maxExpansions lenient boost) =
analyzer maxExpansions lenient boost
minShouldMatch
) =
object [ fieldName .= omitNulls base ]
where base = [ "query" .= mqQueryString
, "operator" .= booleanOperator
Expand All @@ -2934,7 +2938,9 @@ instance ToJSON MatchQuery where
, "analyzer" .= analyzer
, "max_expansions" .= maxExpansions
, "lenient" .= lenient
, "boost" .= boost ]
, "boost" .= boost
, "minimum_should_match" .= minShouldMatch
]

instance FromJSON MatchQuery where
parseJSON = withObject "MatchQuery" parse
Expand All @@ -2949,6 +2955,7 @@ instance FromJSON MatchQuery where
<*> o .:? "max_expansions"
<*> o .:? "lenient"
<*> o .:? "boost"
<*> o .:? "minimum_should_match"

instance ToJSON MultiMatchQuery where
toJSON (MultiMatchQuery fields (QueryString query) boolOp
Expand Down

0 comments on commit 07f6bc5

Please sign in to comment.