git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #40 from silkapp/boost-in-match-query

Add support for boosting fields in match query

commitd87027d4c5d53c579cee604f235d922e12728a43 authorChris Allen <cma@bitemyapp.com> dateMon 31 Aug 2015, 11:03 (11 years ago) parent68ff8c2984ca41
2 files changed+8−6
src/Database/Bloodhound/Client.hs+2−2 src/Database/Bloodhound/Types.hs+6−4
src/Database/Bloodhound/Client.hs+2−2
@@ -617,9 +617,9 @@ mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing
617617-- >>> let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
618618-- >>> let search = mkSearch (Just query) Nothing
619619-- >>> search
620−-- Search {queryBody = Just (QueryMatchQuery (MatchQuery {matchQueryField = FieldName "_all", matchQueryQueryString = QueryString "haskell", matchQueryOperator = Or, matchQueryZeroTerms = ZeroTermsNone, matchQueryCutoffFrequency = Nothing, matchQueryMatchType = Nothing, matchQueryAnalyzer = Nothing, matchQueryMaxExpansions = Nothing, matchQueryLenient = Nothing})), filterBody = Nothing, sortBody = Nothing, aggBody = Nothing, highlight = Nothing, trackSortScores = False, from = From 0, size = Size 10, searchType = SearchTypeQueryThenFetch, fields = Nothing, source = Nothing}
620+-- Search {queryBody = Just (QueryMatchQuery (MatchQuery {matchQueryField = FieldName "_all", matchQueryQueryString = QueryString "haskell", matchQueryOperator = Or, matchQueryZeroTerms = ZeroTermsNone, matchQueryCutoffFrequency = Nothing, matchQueryMatchType = Nothing, matchQueryAnalyzer = Nothing, matchQueryMaxExpansions = Nothing, matchQueryLenient = Nothing, matchQueryBoost = Nothing})), filterBody = Nothing, sortBody = Nothing, aggBody = Nothing, highlight = Nothing, trackSortScores = False, from = From 0, size = Size 10, searchType = SearchTypeQueryThenFetch, fields = Nothing, source = Nothing}
621621-- >>> pageSearch (From 10) (Size 100) search
622−-- Search {queryBody = Just (QueryMatchQuery (MatchQuery {matchQueryField = FieldName "_all", matchQueryQueryString = QueryString "haskell", matchQueryOperator = Or, matchQueryZeroTerms = ZeroTermsNone, matchQueryCutoffFrequency = Nothing, matchQueryMatchType = Nothing, matchQueryAnalyzer = Nothing, matchQueryMaxExpansions = Nothing, matchQueryLenient = Nothing})), filterBody = Nothing, sortBody = Nothing, aggBody = Nothing, highlight = Nothing, trackSortScores = False, from = From 10, size = Size 100, searchType = SearchTypeQueryThenFetch, fields = Nothing, source = Nothing}
622+-- Search {queryBody = Just (QueryMatchQuery (MatchQuery {matchQueryField = FieldName "_all", matchQueryQueryString = QueryString "haskell", matchQueryOperator = Or, matchQueryZeroTerms = ZeroTermsNone, matchQueryCutoffFrequency = Nothing, matchQueryMatchType = Nothing, matchQueryAnalyzer = Nothing, matchQueryMaxExpansions = Nothing, matchQueryLenient = Nothing, matchQueryBoost = Nothing})), filterBody = Nothing, sortBody = Nothing, aggBody = Nothing, highlight = Nothing, trackSortScores = False, from = From 10, size = Size 100, searchType = SearchTypeQueryThenFetch, fields = Nothing, source = Nothing}
623623pageSearch :: From -- ^ The result offset
624624 -> Size -- ^ The number of results to return
625625 -> Search -- ^ The current seach
src/Database/Bloodhound/Types.hs+6−4
@@ -1051,13 +1051,14 @@ data MatchQuery =
10511051 , matchQueryMatchType :: Maybe MatchQueryType
10521052 , matchQueryAnalyzer :: Maybe Analyzer
10531053 , matchQueryMaxExpansions :: Maybe MaxExpansions
1054− , matchQueryLenient :: Maybe Lenient } deriving (Eq, Show)
1054+ , matchQueryLenient :: Maybe Lenient
1055+ , matchQueryBoost :: Maybe Boost } deriving (Eq, Show)
10551056
10561057{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
10571058 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
10581059-}
10591060mkMatchQuery :: FieldName -> QueryString -> MatchQuery
1060−mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing
1061+mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothing Nothing Nothing Nothing Nothing
10611062
10621063data MatchQueryType =
10631064 MatchPhrase
@@ -1987,7 +1988,7 @@ instance ToJSON MatchQuery where
19871988 toJSON (MatchQuery (FieldName fieldName)
19881989 (QueryString mqQueryString) booleanOperator
19891990 zeroTermsQuery cutoffFrequency matchQueryType
1990− analyzer maxExpansions lenient) =
1991+ analyzer maxExpansions lenient boost) =
19911992 object [ fieldName .= omitNulls base ]
19921993 where base = [ "query" .= mqQueryString
19931994 , "operator" .= booleanOperator
@@ -1996,7 +1997,8 @@ instance ToJSON MatchQuery where
19961997 , "type" .= matchQueryType
19971998 , "analyzer" .= analyzer
19981999 , "max_expansions" .= maxExpansions
1999− , "lenient" .= lenient ]
2000+ , "lenient" .= lenient
2001+ , "boost" .= boost ]
20002002
20012003
20022004instance ToJSON MultiMatchQuery where