mirror of
https://github.com/typeable/bloodhound.git
synced 2024-11-29 23:52:20 +03:00
sort documentation, nicer types
This commit is contained in:
parent
1de5b91a86
commit
ce3e658fd0
@ -188,14 +188,17 @@ unpackId :: DocId -> String
|
||||
unpackId (DocId docId) = docId
|
||||
|
||||
type Boost = Double
|
||||
type TrackSortScores = Bool
|
||||
type From = Int
|
||||
type Size = Int
|
||||
|
||||
data Search = Search { queryBody :: Maybe Query
|
||||
, filterBody :: Maybe Filter
|
||||
, sortBody :: Maybe Sort
|
||||
-- default False
|
||||
, trackSortScores :: Bool
|
||||
, from :: Int
|
||||
, size :: Int} deriving (Eq, Show)
|
||||
, trackSortScores :: TrackSortScores
|
||||
, from :: From
|
||||
, size :: Size} deriving (Eq, Show)
|
||||
|
||||
data Query = TermQuery Term (Maybe Boost)
|
||||
| ConstantScoreFilter Filter Boost
|
||||
|
23
README.org
23
README.org
@ -285,6 +285,29 @@ Right [Hit {hitIndex = IndexName "twitter"
|
||||
|
||||
#+BEGIN_SRC haskell
|
||||
|
||||
let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
|
||||
|
||||
-- mkSort is a shortcut function that takes a FieldName and a SortOrder
|
||||
-- to generate a vanilla DefaultSort.
|
||||
-- checkt the DefaultSort type for the full list of customizable options.
|
||||
|
||||
-- From and size are integers for pagination.
|
||||
|
||||
-- When sorting on a field, scores are not computed. By setting TrackSortScores to true, scores will still be computed and tracked.
|
||||
|
||||
-- type Sort = [SortSpec]
|
||||
-- type TrackSortScores = Bool
|
||||
-- type From = Int
|
||||
-- type Size = Int
|
||||
|
||||
-- Search takes Maybe Query
|
||||
-- -> Maybe Filter
|
||||
-- -> Maybe Sort
|
||||
-- -> TrackSortScores
|
||||
-- -> From -> Size
|
||||
|
||||
let search = Search Nothing (Just IdentityFilter) (Just [sortSpec]) False 0 10
|
||||
|
||||
#+END_SRC
|
||||
|
||||
*** Filtering
|
||||
|
Loading…
Reference in New Issue
Block a user