git.iko.soy/typeable/bloodhound
on master help sign in
Small doc fixes
fbe3384Anna Kopp
README.md+2−2
@@ -261,7 +261,7 @@ let maybeResult = decode body :: Maybe (EsResult Tweet)
261
261
262-- use either if you want to know why something failed to parse.
262-- use either if you want to know why something failed to parse.
263-- (string errors, sadly)
263-- (string errors, sadly)
264−let eitherResult = decode body :: Either String (EsResult Tweet)
264+let eitherResult = eitherDecode body :: Either String (EsResult Tweet)
265
265
266-- print eitherResult should look like:
266-- print eitherResult should look like:
267Right (EsResult {_index = "twitter"
267Right (EsResult {_index = "twitter"
@@ -278,7 +278,7 @@ Right (EsResult {_index = "twitter"
278-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
278-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
279
279
280-- use the _source record accessor to get at your document
280-- use the _source record accessor to get at your document
281−λ> fmap _source result
281+fmap _source eitherResult
282Right (Tweet {user = "bitemyapp"
282Right (Tweet {user = "bitemyapp"
283 , postDate = 2009-06-18 00:00:10 UTC
283 , postDate = 2009-06-18 00:00:10 UTC
284 , message = "Use haskell!"
284 , message = "Use haskell!"
src/Database/Bloodhound/Client.hs+9−4
@@ -462,8 +462,10 @@ mkAggregateSearch query mkSearchAggs = Search query Nothing Nothing (Just mkSear
462mkHighlightSearch :: Maybe Query -> Highlights -> Search
462mkHighlightSearch :: Maybe Query -> Highlights -> Search
463mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing (Just searchHighlights) False 0 10
463mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing (Just searchHighlights) False 0 10
464
464
465−-- | 'pageSearch' is a helper function that takes a search and assigns the page from and to
465+-- | 'pageSearch' is a helper function that takes a search and assigns the from
466−-- fields for the search.
466+-- and size fields for the search. The from parameter defines the offset
467+-- from the first result you want to fetch. The size parameter allows you to
468+-- configure the maximum amount of hits to be returned.
467--
469--
468-- >>> let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
470-- >>> let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
469-- >>> let search = mkSearch (Just query) Nothing
471-- >>> let search = mkSearch (Just query) Nothing
@@ -471,5 +473,8 @@ mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing
471-- 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 = 0, size = 10}
473-- 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 = 0, size = 10}
472-- >>> pageSearch 10 100 search
474-- >>> pageSearch 10 100 search
473-- 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 = 10, size = 100}
475-- 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 = 10, size = 100}
474−pageSearch :: Int -> Int -> Search -> Search
476+pageSearch :: Int -- ^ The result offset
477+ -> Int -- ^ The number of results to return
478+ -> Search -- ^ The current seach
479+ -> Search -- ^ The paged search
475−pageSearch pageFrom pageSize search = search { from = pageFrom, size = pageSize }
480+pageSearch resultOffset pageSize search = search { from = resultOffset, size = pageSize }