git.iko.soy/typeable/bloodhound
on master help sign in
Merge branch 'master' of github.com:bitemyapp/bloodhound
commit6e68a227e42d54a66637ad5463ccdfb194a13cf0 authorChris Allen <cma@bitemyapp.com> dateFri 6 Feb 2015, 15:28 (12 years ago) parentb3fbe91ff45170
2 files changed+11−6
README.md+2−2 src/Database/Bloodhound/Client.hs+9−4
README.md+2−2
@@ -266,7 +266,7 @@ let maybeResult = decode body :: Maybe (EsResult Tweet)
266266
267267-- use either if you want to know why something failed to parse.
268268-- (string errors, sadly)
269−let eitherResult = decode body :: Either String (EsResult Tweet)
269+let eitherResult = eitherDecode body :: Either String (EsResult Tweet)
270270
271271-- print eitherResult should look like:
272272Right (EsResult {_index = "twitter"
@@ -283,7 +283,7 @@ Right (EsResult {_index = "twitter"
283283-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
284284
285285-- use the _source record accessor to get at your document
286−λ> fmap _source result
286+fmap _source eitherResult
287287Right (Tweet {user = "bitemyapp"
288288 , postDate = 2009-06-18 00:00:10 UTC
289289 , 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 }