@@ -1,13 +1,25 @@
1{-# LANGUAGE DeriveGeneric #-}
1{-# LANGUAGE DeriveGeneric #-}
2+{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
5+-------------------------------------------------------------------------------
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
4−{-| Data types for describing actions and data structures performed to interact
14+-- Data types for describing actions and data structures performed to interact
5− with Elasticsearch. The two main buckets your queries against Elasticsearch
15+-- 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
16+-- will fall into are 'Query's and 'Filter's. 'Filter's are more like
7− traditional database constraints and often have preferable performance
17+-- traditional database constraints and often have preferable performance
8− properties. 'Query's support human-written textual queries, such as fuzzy
18+-- properties. 'Query's support human-written textual queries, such as fuzzy
9− queries.
19+-- queries.
10−-}
20+-------------------------------------------------------------------------------
12module Database.Bloodhound.Types
24module Database.Bloodhound.Types
13 ( defaultCache
25 ( defaultCache
@@ -197,6 +209,16 @@ import qualified Network.HTTP.Types.Method as NHTM
198import Database.Bloodhound.Types.Class
210import Database.Bloodhound.Types.Class
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"
220+-- defaultIndexSettings is exported by Database.Bloodhound as well
221+-- >>> let defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
201{-| 'Version' is embedded in 'Status' -}
223{-| 'Version' is embedded in 'Status' -}
202data Version = Version { number :: Text
224data Version = Version { number :: Text
@@ -1007,7 +1029,7 @@ data DistanceRange =
1007 DistanceRange { distanceFrom :: Distance
1029 DistanceRange { distanceFrom :: Distance
1008 , distanceTo :: Distance } deriving (Eq, Show)
1030 , distanceTo :: Distance } deriving (Eq, Show)
1010−data (FromJSON a) => SearchResult a =
1032+data SearchResult a =
1011 SearchResult { took :: Int
1033 SearchResult { took :: Int
1012 , timedOut :: Bool
1034 , timedOut :: Bool
1013 , shards :: ShardResult
1035 , shards :: ShardResult
@@ -1016,12 +1038,12 @@ data (FromJSON a) => SearchResult a =
1017type Score = Double
1039type Score = Double
1019−data (FromJSON a) => SearchHits a =
1041+data SearchHits a =
1020 SearchHits { hitsTotal :: Int
1042 SearchHits { hitsTotal :: Int
1021 , maxScore :: Score
1043 , maxScore :: Score
1022 , hits :: [Hit a] } deriving (Eq, Show)
1044 , hits :: [Hit a] } deriving (Eq, Show)
1024−data (FromJSON a) => Hit a =
1046+data Hit a =
1025 Hit { hitIndex :: IndexName
1047 Hit { hitIndex :: IndexName
1026 , hitType :: MappingName
1048 , hitType :: MappingName
1027 , hitDocId :: DocId
1049 , hitDocId :: DocId
@@ -1186,7 +1208,7 @@ class BucketAggregation a where
1186 aggs :: a -> Maybe AggregationResults
1208 aggs :: a -> Maybe AggregationResults
1189−data (FromJSON a, BucketAggregation a) => Bucket a = Bucket { buckets :: [a]} deriving (Show)
1211+data Bucket a = Bucket { buckets :: [a]} deriving (Show)
1191data TermsResult = TermsResult { termKey :: Text
1213data TermsResult = TermsResult { termKey :: Text
1192 , termsDocCount :: Int
1214 , termsDocCount :: Int