git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #23 from annakopp/doc_fixes

Small doc fixes

commitff451707a051e2377b346e32b7ad609c33c660a3 authorChris Allen <cma@bitemyapp.com> dateFri 23 Jan 2015, 18:05 (12 years ago) parent5a7e9e6fbe3384
2 files changed+11−6
README.md+2−2 src/Database/Bloodhound/Client.hs+9−4
README.md+2−2
@@ -261,7 +261,7 @@ let maybeResult = decode body :: Maybe (EsResult Tweet)
261261
262262-- use either if you want to know why something failed to parse.
263263-- (string errors, sadly)
264−let eitherResult = decode body :: Either String (EsResult Tweet)
264+let eitherResult = eitherDecode body :: Either String (EsResult Tweet)
265265
266266-- print eitherResult should look like:
267267Right (EsResult {_index = "twitter"
@@ -278,7 +278,7 @@ Right (EsResult {_index = "twitter"
278278-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
279279
280280-- use the _source record accessor to get at your document
281−λ> fmap _source result
281+fmap _source eitherResult
282282Right (Tweet {user = "bitemyapp"
283283 , postDate = 2009-06-18 00:00:10 UTC
284284 , message = "Use haskell!"
src/Database/Bloodhound/Client.hs+9−4
@@ -462,8 +462,10 @@ mkAggregateSearch query mkSearchAggs = Search query Nothing Nothing (Just mkSear
462462mkHighlightSearch :: Maybe Query -> Highlights -> Search
463463mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing (Just searchHighlights) False 0 10
464464
465−-- | 'pageSearch' is a helper function that takes a search and assigns the page from and to
466−-- fields for the search.
465+-- | 'pageSearch' is a helper function that takes a search and assigns the from
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.
467469--
468470-- >>> let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
469471-- >>> let search = mkSearch (Just query) Nothing
@@ -471,5 +473,8 @@ mkHighlightSearch query searchHighlights = Search query Nothing Nothing Nothing
471473-- 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}
472474-- >>> pageSearch 10 100 search
473475-- 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
475−pageSearch pageFrom pageSize search = search { from = pageFrom, size = pageSize }
476+pageSearch :: Int -- ^ The result offset
477+ -> Int -- ^ The number of results to return
478+ -> Search -- ^ The current seach
479+ -> Search -- ^ The paged search
480+pageSearch resultOffset pageSize search = search { from = resultOffset, size = pageSize }