@@ -1,13 +1,25 @@
11{-# LANGUAGE DeriveGeneric #-}
2+{-# LANGUAGE OverloadedStrings #-}
23{-# LANGUAGE RecordWildCards #-}
34
4−{-| Data types for describing actions and data structures performed to interact
5− with Elasticsearch. The two main buckets your queries against Elasticsearch
6− will fall into are 'Query's and 'Filter's. 'Filter's are more like
7− traditional database constraints and often have preferable performance
8− properties. 'Query's support human-written textual queries, such as fuzzy
9− queries.
10−-}
5+-------------------------------------------------------------------------------
6+-- |
7+-- Module : Database.Bloodhound.Types
8+-- Copyright : (C) 2014 Chris Allen
9+-- License : BSD-style (see the file LICENSE)
10+-- Maintainer : Chris Allen <cma@bitemyapp.com
11+-- Stability : provisional
12+-- Portability : DeriveGeneric, RecordWildCards
13+--
14+-- Data types for describing actions and data structures performed to interact
15+-- with Elasticsearch. The two main buckets your queries against Elasticsearch
16+-- will fall into are 'Query's and 'Filter's. 'Filter's are more like
17+-- traditional database constraints and often have preferable performance
18+-- properties. 'Query's support human-written textual queries, such as fuzzy
19+-- queries.
20+-------------------------------------------------------------------------------
21+
22+
1123
1224module Database.Bloodhound.Types
1325 ( defaultCache
@@ -197,6 +209,16 @@ import qualified Network.HTTP.Types.Method as NHTM
197209
198210import Database.Bloodhound.Types.Class
199211
212+-- $setup
213+-- >>> :set -XOverloadedStrings
214+-- >>> import Database.Bloodhound
215+-- no trailing slashes in servers, library handles building the path.
216+-- >>> let testServer = (Server "http://localhost:9200")
217+-- >>> let testIndex = IndexName "twitter"
218+-- >>> let testMapping = MappingName "tweet"
219+
220+-- defaultIndexSettings is exported by Database.Bloodhound as well
221+-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
200222
201223{-| 'Version' is embedded in 'Status' -}
202224data Version = Version { number :: Text
@@ -1007,7 +1029,7 @@ data DistanceRange =
10071029 DistanceRange { distanceFrom :: Distance
10081030 , distanceTo :: Distance } deriving (Eq, Show)
10091031
1010−data (FromJSON a) => SearchResult a =
1032+data SearchResult a =
10111033 SearchResult { took :: Int
10121034 , timedOut :: Bool
10131035 , shards :: ShardResult
@@ -1016,12 +1038,12 @@ data (FromJSON a) => SearchResult a =
10161038
10171039type Score = Double
10181040
1019−data (FromJSON a) => SearchHits a =
1041+data SearchHits a =
10201042 SearchHits { hitsTotal :: Int
10211043 , maxScore :: Score
10221044 , hits :: [Hit a] } deriving (Eq, Show)
10231045
1024−data (FromJSON a) => Hit a =
1046+data Hit a =
10251047 Hit { hitIndex :: IndexName
10261048 , hitType :: MappingName
10271049 , hitDocId :: DocId
@@ -1186,7 +1208,7 @@ class BucketAggregation a where
11861208 aggs :: a -> Maybe AggregationResults
11871209
11881210
1189−data (FromJSON a, BucketAggregation a) => Bucket a = Bucket { buckets :: [a]} deriving (Show)
1211+data Bucket a = Bucket { buckets :: [a]} deriving (Show)
11901212
11911213data TermsResult = TermsResult { termKey :: Text
11921214 , termsDocCount :: Int