git.iko.soy/typeable/bloodhound
on master help sign in
Elastic 5.0 compatibility
437bc3dJosh Berman
bloodhound.cabal → bloodhound5.cabalrenamed+4−4
@@ -1,4 +1,4 @@
1−name: bloodhound
1+name: bloodhound5
2version: 0.12.0.0
2version: 0.12.0.0
3synopsis: ElasticSearch client library for Haskell
3synopsis: ElasticSearch client library for Haskell
4description: ElasticSearch made awesome for Haskell hackers
4description: ElasticSearch made awesome for Haskell hackers
@@ -57,7 +57,7 @@ test-suite tests
57 main-is: tests.hs
57 main-is: tests.hs
58 hs-source-dirs: tests
58 hs-source-dirs: tests
59 build-depends: base,
59 build-depends: base,
60− bloodhound,
60+ bloodhound5,
61 bytestring,
61 bytestring,
62 http-client,
62 http-client,
63 http-types,
63 http-types,
@@ -76,7 +76,7 @@ test-suite tests
76 errors,
76 errors,
77 exceptions,
77 exceptions,
78 temporary,
78 temporary,
79− unix,
79+ unix-compat,
80 network-uri
80 network-uri
81 default-language: Haskell2010
81 default-language: Haskell2010
82
82
@@ -89,7 +89,7 @@ test-suite doctests
89 if impl(ghc >= 7.8)
89 if impl(ghc >= 7.8)
90 build-depends: base,
90 build-depends: base,
91 aeson,
91 aeson,
92− bloodhound,
92+ bloodhound5,
93 directory,
93 directory,
94 doctest >= 0.10.1,
94 doctest >= 0.10.1,
95 filepath
95 filepath
src/Database/Bloodhound/Client.hs+66−63
@@ -28,7 +28,7 @@ module Database.Bloodhound.Client
28 , deleteIndex
28 , deleteIndex
29 , updateIndexSettings
29 , updateIndexSettings
30 , getIndexSettings
30 , getIndexSettings
31− , optimizeIndex
31+ , forceMergeIndex
32 , indexExists
32 , indexExists
33 , openIndex
33 , openIndex
34 , closeIndex
34 , closeIndex
@@ -43,7 +43,6 @@ module Database.Bloodhound.Client
43 , deleteTemplate
43 , deleteTemplate
44 -- ** Mapping
44 -- ** Mapping
45 , putMapping
45 , putMapping
46− , deleteMapping
47 -- ** Documents
46 -- ** Documents
48 , indexDocument
47 , indexDocument
49 , updateDocument
48 , updateDocument
@@ -133,7 +132,8 @@ import Database.Bloodhound.Types
133-- >>> let testMapping = MappingName "tweet"
132-- >>> let testMapping = MappingName "tweet"
134-- >>> let defaultIndexSettings = IndexSettings (ShardCount 1) (ReplicaCount 0)
133-- >>> let defaultIndexSettings = IndexSettings (ShardCount 1) (ReplicaCount 0)
135-- >>> data TweetMapping = TweetMapping deriving (Eq, Show)
134-- >>> data TweetMapping = TweetMapping deriving (Eq, Show)
136−-- >>> _ <- runBH' $ deleteIndex testIndex >> deleteMapping testIndex testMapping
135+-- >>> _ <- runBH' $ deleteIndex testIndex
136+-- >>> _ <- runBH' $ deleteIndex (IndexName "didimakeanindex")
137-- >>> import GHC.Generics
137-- >>> import GHC.Generics
138-- >>> import Data.Time.Calendar (Day (..))
138-- >>> import Data.Time.Calendar (Day (..))
139-- >>> import Data.Time.Clock (UTCTime (..), secondsToDiffTime)
139-- >>> import Data.Time.Clock (UTCTime (..), secondsToDiffTime)
@@ -224,12 +224,8 @@ appendSearchTypeParam originalUrl st = addQuery params originalUrl
224 where stText = "search_type"
224 where stText = "search_type"
225 params
225 params
226 | st == SearchTypeDfsQueryThenFetch = [(stText, Just "dfs_query_then_fetch")]
226 | st == SearchTypeDfsQueryThenFetch = [(stText, Just "dfs_query_then_fetch")]
227− | st == SearchTypeCount = [(stText, Just "count")]
228− | st == SearchTypeScan = [(stText, Just "scan"), ("scroll", Just "1m")]
229− | st == SearchTypeQueryAndFetch = [(stText, Just "query_and_fetch")]
230− | st == SearchTypeDfsQueryAndFetch = [(stText, Just "dfs_query_and_fetch")]
231 -- used to catch 'SearchTypeQueryThenFetch', which is also the default
227 -- used to catch 'SearchTypeQueryThenFetch', which is also the default
232− | otherwise = [(stText, Just "query_then_fetch")]
228+ | otherwise = []
233
229
234-- | Severely dumbed down query renderer. Assumes your data doesn't
230-- | Severely dumbed down query renderer. Assumes your data doesn't
235-- need any encoding
231-- need any encoding
@@ -273,8 +269,8 @@ post = dispatch NHTM.methodPost
273-- | 'getStatus' fetches the 'Status' of a 'Server'
269-- | 'getStatus' fetches the 'Status' of a 'Server'
274--
270--
275-- >>> serverStatus <- runBH' getStatus
271-- >>> serverStatus <- runBH' getStatus
276−-- >>> fmap status (serverStatus)
272+-- >>> fmap tagline (serverStatus)
277−-- Just 200
273+-- Just "You Know, for Search"
278getStatus :: MonadBH m => m (Maybe Status)
274getStatus :: MonadBH m => m (Maybe Status)
279getStatus = do
275getStatus = do
280 response <- get =<< url
276 response <- get =<< url
@@ -513,7 +509,7 @@ createIndex indexSettings (IndexName indexName) =
513-- >>> response <- runBH' $ deleteIndex (IndexName "didimakeanindex")
509-- >>> response <- runBH' $ deleteIndex (IndexName "didimakeanindex")
514-- >>> respIsTwoHunna response
510-- >>> respIsTwoHunna response
515-- True
511-- True
516−-- >>> runBH' $ indexExists testIndex
512+-- >>> runBH' $ indexExists (IndexName "didimakeanindex")
517-- False
513-- False
518deleteIndex :: MonadBH m => IndexName -> m Reply
514deleteIndex :: MonadBH m => IndexName -> m Reply
519deleteIndex (IndexName indexName) =
515deleteIndex (IndexName indexName) =
@@ -540,33 +536,36 @@ getIndexSettings (IndexName indexName) = do
540 where url = joinPath [indexName, "_settings"]
536 where url = joinPath [indexName, "_settings"]
541
537
542
538
543−-- | 'optimizeIndex' will optimize a single index, list of indexes or
539+-- | 'forceMergeIndex'
544−-- all indexes. Note that this call will block until finishing but
540+--
545−-- will continue even if the request times out. Concurrent requests to
541+-- The force merge API allows to force merging of one or more indices through
546−-- optimize an index while another is performing will block until the
542+-- an API. The merge relates to the number of segments a Lucene index holds
543+-- within each shard. The force merge operation allows to reduce the number of
544+-- segments by merging them.
545+--
546+-- This call will block until the merge is complete. If the http connection is
547+-- lost, the request will continue in the background, and any new requests will
548+-- block until the previous force merge is complete.
549+
547−-- previous one finishes. For more information see
550+-- For more information see
548−-- <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-optimize.html>. Nothing
551+-- <https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html#indices-forcemerge>.
552+-- Nothing
549-- worthwhile comes back in the reply body, so matching on the status
553-- worthwhile comes back in the reply body, so matching on the status
550-- should suffice.
554-- should suffice.
551--
555--
552−-- 'optimizeIndex' with a maxNumSegments of 1 and onlyExpungeDeletes
556+-- 'forceMergeIndex' with a maxNumSegments of 1 and onlyExpungeDeletes
553-- to True is the main way to release disk space back to the OS being
557-- to True is the main way to release disk space back to the OS being
554-- held by deleted documents.
558-- held by deleted documents.
555--
559--
556−-- Note that this API was deprecated in ElasticSearch 2.1 for the
557−-- almost completely identical forcemerge API. Adding support to that
558−-- API would be trivial but due to the significant breaking changes,
559−-- this library cannot currently be used with >= 2.0, so that feature was omitted.
560−--
561-- >>> let ixn = IndexName "unoptimizedindex"
560-- >>> let ixn = IndexName "unoptimizedindex"
562-- >>> _ <- runBH' $ deleteIndex ixn >> createIndex defaultIndexSettings ixn
561-- >>> _ <- runBH' $ deleteIndex ixn >> createIndex defaultIndexSettings ixn
563−-- >>> response <- runBH' $ optimizeIndex (IndexList (ixn :| [])) (defaultIndexOptimizationSettings { maxNumSegments = Just 1, onlyExpungeDeletes = True })
562+-- >>> response <- runBH' $ forceMergeIndex (IndexList (ixn :| [])) (defaultIndexOptimizationSettings { maxNumSegments = Just 1, onlyExpungeDeletes = True })
564-- >>> respIsTwoHunna response
563-- >>> respIsTwoHunna response
565-- True
564-- True
566−optimizeIndex :: MonadBH m => IndexSelection -> IndexOptimizationSettings -> m Reply
565+forceMergeIndex :: MonadBH m => IndexSelection -> ForceMergeIndexSettings -> m Reply
567−optimizeIndex ixs IndexOptimizationSettings {..} =
566+forceMergeIndex ixs ForceMergeIndexSettings {..} =
568 bindM2 post url (return body)
567 bindM2 post url (return body)
569− where url = addQuery params <$> joinPath [indexName, "_optimize"]
568+ where url = addQuery params <$> joinPath [indexName, "_forcemerge"]
570 params = catMaybes [ ("max_num_segments",) . Just . showText <$> maxNumSegments
569 params = catMaybes [ ("max_num_segments",) . Just . showText <$> maxNumSegments
571 , Just ("only_expunge_deletes", Just (boolQP onlyExpungeDeletes))
570 , Just ("only_expunge_deletes", Just (boolQP onlyExpungeDeletes))
572 , Just ("flush", Just (boolQP flushAfterOptimize))
571 , Just ("flush", Just (boolQP flushAfterOptimize))
@@ -745,7 +744,7 @@ deleteTemplate (TemplateName templateName) =
745-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
744-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
746-- >>> resp <- runBH' $ putMapping testIndex testMapping TweetMapping
745-- >>> resp <- runBH' $ putMapping testIndex testMapping TweetMapping
747-- >>> print resp
746-- >>> print resp
748−-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
747+-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("transfer-encoding","chunked")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
749putMapping :: (MonadBH m, ToJSON a) => IndexName
748putMapping :: (MonadBH m, ToJSON a) => IndexName
750 -> MappingName -> a -> m Reply
749 -> MappingName -> a -> m Reply
751putMapping (IndexName indexName) (MappingName mappingName) mapping =
750putMapping (IndexName indexName) (MappingName mappingName) mapping =
@@ -755,21 +754,6 @@ putMapping (IndexName indexName) (MappingName mappingName) mapping =
755 -- erroneously. The correct API call is: "/INDEX/_mapping/MAPPING_NAME"
754 -- erroneously. The correct API call is: "/INDEX/_mapping/MAPPING_NAME"
756 body = Just $ encode mapping
755 body = Just $ encode mapping
757
756
758−-- | 'deleteMapping' is an HTTP DELETE and deletes a mapping for a given index.
759−-- Mappings are schemas for documents in indexes.
760−--
761−-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
762−-- >>> _ <- runBH' $ putMapping testIndex testMapping TweetMapping
763−-- >>> resp <- runBH' $ deleteMapping testIndex testMapping
764−-- >>> print resp
765−-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","21")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
766−deleteMapping :: MonadBH m => IndexName -> MappingName -> m Reply
767−deleteMapping (IndexName indexName)
768− (MappingName mappingName) =
769− -- "_mapping" and mappingName below were originally transposed
770− -- erroneously. The correct API call is: "/INDEX/_mapping/MAPPING_NAME"
771− delete =<< joinPath [indexName, "_mapping", mappingName]
772−
773versionCtlParams :: IndexDocumentSettings -> [(Text, Maybe Text)]
757versionCtlParams :: IndexDocumentSettings -> [(Text, Maybe Text)]
774versionCtlParams cfg =
758versionCtlParams cfg =
775 case idsVersionControl cfg of
759 case idsVersionControl cfg of
@@ -791,7 +775,7 @@ versionCtlParams cfg =
791--
775--
792-- >>> resp <- runBH' $ indexDocument testIndex testMapping defaultIndexDocumentSettings exampleTweet (DocId "1")
776-- >>> resp <- runBH' $ indexDocument testIndex testMapping defaultIndexDocumentSettings exampleTweet (DocId "1")
793-- >>> print resp
777-- >>> print resp
794−-- Response {responseStatus = Status {statusCode = 201, statusMessage = "Created"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Type","application/json; charset=UTF-8"),("Content-Length","74")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":1,\"created\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
778+-- Response {responseStatus = Status {statusCode = 201, statusMessage = "Created"}, responseVersion = HTTP/1.1, responseHeaders = [("Location","/twitter/tweet/1"),("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("transfer-encoding","chunked")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"created\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
795indexDocument :: (ToJSON doc, MonadBH m) => IndexName -> MappingName
779indexDocument :: (ToJSON doc, MonadBH m) => IndexName -> MappingName
796 -> IndexDocumentSettings -> doc -> DocId -> m Reply
780 -> IndexDocumentSettings -> doc -> DocId -> m Reply
797indexDocument (IndexName indexName)
781indexDocument (IndexName indexName)
@@ -958,16 +942,21 @@ searchByType (IndexName indexName)
958-- search results. Note that the search is put into 'SearchTypeScan'
942-- search results. Note that the search is put into 'SearchTypeScan'
959-- mode and thus results will not be sorted. Combine this with
943-- mode and thus results will not be sorted. Combine this with
960-- 'advanceScroll' to efficiently stream through the full result set
944-- 'advanceScroll' to efficiently stream through the full result set
961−getInitialScroll :: MonadBH m => IndexName -> MappingName -> Search -> m (Maybe ScrollId)
945+getInitialScroll ::
946+ (FromJSON a, MonadThrow m, MonadBH m) => IndexName ->
947+ MappingName ->
948+ Search ->
949+ m (Either EsError (SearchResult a))
962−getInitialScroll (IndexName indexName) (MappingName mappingName) search = do
950+getInitialScroll (IndexName indexName) (MappingName mappingName) search' = do
963− let url = joinPath [indexName, mappingName, "_search"]
951+ let url = addQuery params <$> joinPath [indexName, mappingName, "_search"]
964− search' = search { searchType = SearchTypeScan }
952+ params = [("scroll", Just "1m")]
953+ sorting = Just [DefaultSortSpec $ mkSort (FieldName "_doc") Descending]
954+ search = search' { sortBody = sorting }
965− resp' <- bindM2 dispatchSearch url (return search')
955+ resp' <- bindM2 dispatchSearch url (return search)
966− let msr = decode' $ responseBody resp' :: Maybe (SearchResult ())
956+ parseEsResponse resp'
967− msid = maybe Nothing scrollId msr
957+
968− return msid
969−
970−scroll' :: (FromJSON a, MonadBH m, MonadThrow m) => Maybe ScrollId -> m ([Hit a], Maybe ScrollId)
958+scroll' :: (FromJSON a, MonadBH m, MonadThrow m) => Maybe ScrollId ->
959+ m ([Hit a], Maybe ScrollId)
971scroll' Nothing = return ([], Nothing)
960scroll' Nothing = return ([], Nothing)
972scroll' (Just sid) = do
961scroll' (Just sid) = do
973 res <- advanceScroll sid 60
962 res <- advanceScroll sid 60
@@ -987,20 +976,29 @@ advanceScroll
987 -- ^ How long should the snapshot of data be kept around? This timeout is updated every time 'advanceScroll' is used, so don't feel the need to set it to the entire duration of your search processing. Note that durations < 1s will be rounded up. Also note that 'NominalDiffTime' is an instance of Num so literals like 60 will be interpreted as seconds. 60s is a reasonable default.
976 -- ^ How long should the snapshot of data be kept around? This timeout is updated every time 'advanceScroll' is used, so don't feel the need to set it to the entire duration of your search processing. Note that durations < 1s will be rounded up. Also note that 'NominalDiffTime' is an instance of Num so literals like 60 will be interpreted as seconds. 60s is a reasonable default.
988 -> m (Either EsError (SearchResult a))
977 -> m (Either EsError (SearchResult a))
989advanceScroll (ScrollId sid) scroll = do
978advanceScroll (ScrollId sid) scroll = do
990− url <- joinPath ["_search/scroll?scroll=" <> scrollTime]
979+ url <- joinPath ["_search", "scroll"]
991− parseEsResponse =<< post url (Just . L.fromStrict $ T.encodeUtf8 sid)
980+ resp <- post url (Just $ encode scrollObject)
981+ parseEsResponse resp
992 where scrollTime = showText secs <> "s"
982 where scrollTime = showText secs <> "s"
993 secs :: Integer
983 secs :: Integer
994 secs = round scroll
984 secs = round scroll
995−
985+
986+ scrollObject = object [ "scroll" .= scrollTime
987+ , "scroll_id" .= sid
988+ ]
989+
990+simpleAccumulator ::
996−simpleAccumulator :: (FromJSON a, MonadBH m, MonadThrow m) => [Hit a] -> ([Hit a], Maybe ScrollId) -> m ([Hit a], Maybe ScrollId)
991+ (FromJSON a, MonadBH m, MonadThrow m) =>
992+ [Hit a] ->
993+ ([Hit a], Maybe ScrollId) ->
994+ m ([Hit a], Maybe ScrollId)
997simpleAccumulator oldHits (newHits, Nothing) = return (oldHits ++ newHits, Nothing)
995simpleAccumulator oldHits (newHits, Nothing) = return (oldHits ++ newHits, Nothing)
998simpleAccumulator oldHits ([], _) = return (oldHits, Nothing)
996simpleAccumulator oldHits ([], _) = return (oldHits, Nothing)
999simpleAccumulator oldHits (newHits, msid) = do
997simpleAccumulator oldHits (newHits, msid) = do
1000 (newHits', msid') <- scroll' msid
998 (newHits', msid') <- scroll' msid
1001 simpleAccumulator (oldHits ++ newHits) (newHits', msid')
999 simpleAccumulator (oldHits ++ newHits) (newHits', msid')
1002
1000
1003−-- | 'scanSearch' uses the 'scan&scroll' API of elastic,
1001+-- | 'scanSearch' uses the 'scroll' API of elastic,
1004-- for a given 'IndexName' and 'MappingName'. Note that this will
1002-- for a given 'IndexName' and 'MappingName'. Note that this will
1005-- consume the entire search result set and will be doing O(n) list
1003-- consume the entire search result set and will be doing O(n) list
1006-- appends so this may not be suitable for large result sets. In that
1004-- appends so this may not be suitable for large result sets. In that
@@ -1009,11 +1007,16 @@ simpleAccumulator oldHits (newHits, msid) = do
1009-- pipes, or your favorite streaming IO abstraction of choice. Note
1007-- pipes, or your favorite streaming IO abstraction of choice. Note
1010-- that ordering on the search would destroy performance and thus is
1008-- that ordering on the search would destroy performance and thus is
1011-- ignored.
1009-- ignored.
1012−scanSearch :: (FromJSON a, MonadBH m, MonadThrow m) => IndexName -> MappingName -> Search -> m [Hit a]
1010+scanSearch :: (FromJSON a, MonadBH m, MonadThrow m) => IndexName
1011+ -> MappingName
1012+ -> Search
1013+ -> m [Hit a]
1013scanSearch indexName mappingName search = do
1014scanSearch indexName mappingName search = do
1014− msid <- getInitialScroll indexName mappingName search
1015+ initialSearchResult <- getInitialScroll indexName mappingName search
1015− (hits, msid') <- scroll' msid
1016+ let (hits', josh) = case initialSearchResult of
1017+ Right SearchResult {..} -> (hits searchHits, scrollId)
1018+ Left _ -> ([], Nothing)
1016− (totalHits, _) <- simpleAccumulator [] (hits, msid')
1019+ (totalHits, _) <- simpleAccumulator [] (hits', josh)
1017 return totalHits
1020 return totalHits
1018
1021
1019-- | 'mkSearch' is a helper function for defaulting additional fields of a 'Search'
1022-- | 'mkSearch' is a helper function for defaulting additional fields of a 'Search'
src/Database/Bloodhound/Types.hs+142−385
@@ -152,8 +152,8 @@ module Database.Bloodhound.Types
152 , IndexSelection(..)
152 , IndexSelection(..)
153 , NodeSelection(..)
153 , NodeSelection(..)
154 , NodeSelector(..)
154 , NodeSelector(..)
155− , IndexOptimizationSettings(..)
155+ , ForceMergeIndexSettings(..)
156− , defaultIndexOptimizationSettings
156+ , defaultForceMergeIndexSettings
157 , TemplateName(..)
157 , TemplateName(..)
158 , TemplatePattern(..)
158 , TemplatePattern(..)
159 , MappingName(..)
159 , MappingName(..)
@@ -178,7 +178,6 @@ module Database.Bloodhound.Types
178 , BoostingQuery(..)
178 , BoostingQuery(..)
179 , CommonTermsQuery(..)
179 , CommonTermsQuery(..)
180 , DisMaxQuery(..)
180 , DisMaxQuery(..)
181− , FilteredQuery(..)
182 , FuzzyLikeThisQuery(..)
181 , FuzzyLikeThisQuery(..)
183 , FuzzyLikeFieldQuery(..)
182 , FuzzyLikeFieldQuery(..)
184 , FuzzyQuery(..)
183 , FuzzyQuery(..)
@@ -452,7 +451,7 @@ runBH e f = runReaderT (unBH f) e
452{-| 'Version' is embedded in 'Status' -}
451{-| 'Version' is embedded in 'Status' -}
453data Version = Version { number :: VersionNumber
452data Version = Version { number :: VersionNumber
454 , build_hash :: BuildHash
453 , build_hash :: BuildHash
455− , build_timestamp :: UTCTime
454+ , build_date :: UTCTime
456 , build_snapshot :: Bool
455 , build_snapshot :: Bool
457 , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
456 , lucene_version :: VersionNumber } deriving (Eq, Read, Show, Generic, Typeable)
458
457
@@ -466,11 +465,11 @@ newtype VersionNumber = VersionNumber { versionNumber :: Vers.Version
466 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html#indices-status>
465 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-status.html#indices-status>
467-}
466-}
468
467
469−data Status = Status { ok :: Maybe Bool
468+data Status = Status { name :: Text
470− , status :: Int
469+ , cluster_name :: Text
471− , name :: Text
470+ , cluster_uuid :: Text
472− , version :: Version
471+ , version :: Version
473− , tagline :: Text } deriving (Eq, Read, Show, Generic)
472+ , tagline :: Text } deriving (Eq, Read, Show, Generic)
474
473
475{-| 'IndexSettings' is used to configure the shards and replicas when you create
474{-| 'IndexSettings' is used to configure the shards and replicas when you create
476 an Elasticsearch Index.
475 an Elasticsearch Index.
@@ -487,12 +486,12 @@ defaultIndexSettings :: IndexSettings
487defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
486defaultIndexSettings = IndexSettings (ShardCount 3) (ReplicaCount 2)
488
487
489
488
490−{-| 'IndexOptimizationSettings' is used to configure index optimization. See
489+{-| 'ForceMergeIndexSettings' is used to configure index optimization. See
491− <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-optimize.html>
490+ <https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html>
492 for more info.
491 for more info.
493-}
492-}
494−data IndexOptimizationSettings =
493+data ForceMergeIndexSettings =
495− IndexOptimizationSettings { maxNumSegments :: Maybe Int
494+ ForceMergeIndexSettings { maxNumSegments :: Maybe Int
496 -- ^ Number of segments to optimize to. 1 will fully optimize the index. If omitted, the default behavior is to only optimize if the server deems it necessary.
495 -- ^ Number of segments to optimize to. 1 will fully optimize the index. If omitted, the default behavior is to only optimize if the server deems it necessary.
497 , onlyExpungeDeletes :: Bool
496 , onlyExpungeDeletes :: Bool
498 -- ^ Should the optimize process only expunge segments with deletes in them? If the purpose of the optimization is to free disk space, this should be set to True.
497 -- ^ Should the optimize process only expunge segments with deletes in them? If the purpose of the optimization is to free disk space, this should be set to True.
@@ -501,12 +500,12 @@ data IndexOptimizationSettings =
501 } deriving (Eq, Show, Generic, Typeable)
500 } deriving (Eq, Show, Generic, Typeable)
502
501
503
502
504−{-| 'defaultIndexOptimizationSettings' implements the default settings that
503+{-| 'defaultForceMergeIndexSettings' implements the default settings that
505 ElasticSearch uses for index optimization. 'maxNumSegments' is Nothing,
504 ElasticSearch uses for index optimization. 'maxNumSegments' is Nothing,
506 'onlyExpungeDeletes' is False, and flushAfterOptimize is True.
505 'onlyExpungeDeletes' is False, and flushAfterOptimize is True.
507-}
506-}
508−defaultIndexOptimizationSettings :: IndexOptimizationSettings
507+defaultForceMergeIndexSettings :: ForceMergeIndexSettings
509−defaultIndexOptimizationSettings = IndexOptimizationSettings Nothing False True
508+defaultForceMergeIndexSettings = ForceMergeIndexSettings Nothing False True
510
509
511{-| 'UpdatableIndexSetting' are settings which may be updated after an index is created.
510{-| 'UpdatableIndexSetting' are settings which may be updated after an index is created.
512
511
@@ -845,6 +844,8 @@ data SortSpec = DefaultSortSpec DefaultSort
845{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
844{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
846 'mkSort' convenience function for when you want to specify only the most
845 'mkSort' convenience function for when you want to specify only the most
847 common parameters.
846 common parameters.
847+
848+ The `ignoreUnmapped`, when `Just` field is used to set the elastic 'unmapped_type'
848
849
849<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
850<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
850-}
851-}
@@ -852,7 +853,7 @@ data DefaultSort =
852 DefaultSort { sortFieldName :: FieldName
853 DefaultSort { sortFieldName :: FieldName
853 , sortOrder :: SortOrder
854 , sortOrder :: SortOrder
854 -- default False
855 -- default False
855− , ignoreUnmapped :: Bool
856+ , ignoreUnmapped :: Maybe Text
856 , sortMode :: Maybe SortMode
857 , sortMode :: Maybe SortMode
857 , missingSort :: Maybe Missing
858 , missingSort :: Maybe Missing
858 , nestedFilter :: Maybe Filter } deriving (Eq, Read, Show, Generic, Typeable)
859 , nestedFilter :: Maybe Filter } deriving (Eq, Read, Show, Generic, Typeable)
@@ -887,7 +888,7 @@ data SortMode = SortMin
887 that you can concisely describe the usual kind of 'SortSpec's you want.
888 that you can concisely describe the usual kind of 'SortSpec's you want.
888-}
889-}
889mkSort :: FieldName -> SortOrder -> DefaultSort
890mkSort :: FieldName -> SortOrder -> DefaultSort
890−mkSort fieldName sOrder = DefaultSort fieldName sOrder False Nothing Nothing Nothing
891+mkSort fieldName sOrder = DefaultSort fieldName sOrder Nothing Nothing Nothing Nothing
891
892
892{-| 'Cache' is for telling ES whether it should cache a 'Filter' not.
893{-| 'Cache' is for telling ES whether it should cache a 'Filter' not.
893 'Query's cannot be cached.
894 'Query's cannot be cached.
@@ -1100,10 +1101,6 @@ data Search = Search { queryBody :: Maybe Query
1100
1101
1101data SearchType = SearchTypeQueryThenFetch
1102data SearchType = SearchTypeQueryThenFetch
1102 | SearchTypeDfsQueryThenFetch
1103 | SearchTypeDfsQueryThenFetch
1103− | SearchTypeCount
1104− | SearchTypeScan
1105− | SearchTypeQueryAndFetch
1106− | SearchTypeDfsQueryAndFetch
1107 deriving (Eq, Read, Show, Generic, Typeable)
1104 deriving (Eq, Read, Show, Generic, Typeable)
1108
1105
1109data Source =
1106data Source =
@@ -1183,10 +1180,8 @@ data Query =
1183 | QueryBoolQuery BoolQuery
1180 | QueryBoolQuery BoolQuery
1184 | QueryBoostingQuery BoostingQuery
1181 | QueryBoostingQuery BoostingQuery
1185 | QueryCommonTermsQuery CommonTermsQuery
1182 | QueryCommonTermsQuery CommonTermsQuery
1186− | ConstantScoreFilter Filter Boost
1187 | ConstantScoreQuery Query Boost
1183 | ConstantScoreQuery Query Boost
1188 | QueryDisMaxQuery DisMaxQuery
1184 | QueryDisMaxQuery DisMaxQuery
1189− | QueryFilteredQuery FilteredQuery
1190 | QueryFuzzyLikeThisQuery FuzzyLikeThisQuery
1185 | QueryFuzzyLikeThisQuery FuzzyLikeThisQuery
1191 | QueryFuzzyLikeFieldQuery FuzzyLikeFieldQuery
1186 | QueryFuzzyLikeFieldQuery FuzzyLikeFieldQuery
1192 | QueryFuzzyQuery FuzzyQuery
1187 | QueryFuzzyQuery FuzzyQuery
@@ -1203,8 +1198,21 @@ data Query =
1203 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
1198 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
1204 | QueryRangeQuery RangeQuery
1199 | QueryRangeQuery RangeQuery
1205 | QueryRegexpQuery RegexpQuery
1200 | QueryRegexpQuery RegexpQuery
1201+ | QueryExistsQuery FieldName
1202+ | QueryMatchNoneQuery
1206 deriving (Eq, Read, Show, Generic, Typeable)
1203 deriving (Eq, Read, Show, Generic, Typeable)
1207
1204
1205+-- | As of Elastic 2.0, 'Filters' are just 'Queries' housed in a Bool Query, and
1206+-- flagged in a different context.
1207+newtype Filter = Filter { unFilter :: Query }
1208+ deriving (Eq, Read, Show, Generic, Typeable)
1209+
1210+instance ToJSON Filter where
1211+ toJSON = toJSON . unFilter
1212+
1213+instance FromJSON Filter where
1214+ parseJSON v = Filter <$> parseJSON v
1215+
1208data RegexpQuery =
1216data RegexpQuery =
1209 RegexpQuery { regexpQueryField :: FieldName
1217 RegexpQuery { regexpQueryField :: FieldName
1210 , regexpQuery :: Regexp
1218 , regexpQuery :: Regexp
@@ -1385,11 +1393,6 @@ data FuzzyLikeThisQuery =
1385 , fuzzyLikeAnalyzer :: Maybe Analyzer
1393 , fuzzyLikeAnalyzer :: Maybe Analyzer
1386 } deriving (Eq, Read, Show, Generic, Typeable)
1394 } deriving (Eq, Read, Show, Generic, Typeable)
1387
1395
1388−data FilteredQuery =
1389− FilteredQuery
1390− { filteredQuery :: Query
1391− , filteredFilter :: Filter } deriving (Eq, Read, Show, Generic, Typeable)
1392−
1393data DisMaxQuery =
1396data DisMaxQuery =
1394 DisMaxQuery { disMaxQueries :: [Query]
1397 DisMaxQuery { disMaxQueries :: [Query]
1395 -- default 0.0
1398 -- default 0.0
@@ -1450,6 +1453,7 @@ data MultiMatchQueryType =
1450
1453
1451data BoolQuery =
1454data BoolQuery =
1452 BoolQuery { boolQueryMustMatch :: [Query]
1455 BoolQuery { boolQueryMustMatch :: [Query]
1456+ , boolQueryFilter :: [Filter]
1453 , boolQueryMustNotMatch :: [Query]
1457 , boolQueryMustNotMatch :: [Query]
1454 , boolQueryShouldMatch :: [Query]
1458 , boolQueryShouldMatch :: [Query]
1455 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
1459 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
@@ -1457,9 +1461,9 @@ data BoolQuery =
1457 , boolQueryDisableCoord :: Maybe DisableCoord
1461 , boolQueryDisableCoord :: Maybe DisableCoord
1458 } deriving (Eq, Read, Show, Generic, Typeable)
1462 } deriving (Eq, Read, Show, Generic, Typeable)
1459
1463
1460−mkBoolQuery :: [Query] -> [Query] -> [Query] -> BoolQuery
1464+mkBoolQuery :: [Query] -> [Filter] -> [Query] -> [Query] -> BoolQuery
1461−mkBoolQuery must mustNot should =
1465+mkBoolQuery must filter mustNot should =
1462− BoolQuery must mustNot should Nothing Nothing Nothing
1466+ BoolQuery must filter mustNot should Nothing Nothing Nothing
1463
1467
1464data BoostingQuery =
1468data BoostingQuery =
1465 BoostingQuery { positiveQuery :: Query
1469 BoostingQuery { positiveQuery :: Query
@@ -1487,26 +1491,6 @@ data MinimumMatchHighLow =
1487 MinimumMatchHighLow { lowFreq :: MinimumMatch
1491 MinimumMatchHighLow { lowFreq :: MinimumMatch
1488 , highFreq :: MinimumMatch } deriving (Eq, Read, Show, Generic, Typeable)
1492 , highFreq :: MinimumMatch } deriving (Eq, Read, Show, Generic, Typeable)
1489
1493
1490−data Filter = AndFilter [Filter] Cache
1491− | OrFilter [Filter] Cache
1492− | NotFilter Filter Cache
1493− | IdentityFilter
1494− | BoolFilter BoolMatch
1495− | ExistsFilter FieldName -- always cached
1496− | GeoBoundingBoxFilter GeoBoundingBoxConstraint
1497− | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
1498− | GeoDistanceRangeFilter GeoPoint DistanceRange
1499− | GeoPolygonFilter FieldName [LatLon]
1500− | IdsFilter MappingName [DocId]
1501− | LimitFilter Int
1502− | MissingFilter FieldName Existence NullValue
1503− | PrefixFilter FieldName PrefixValue Cache
1504− | QueryFilter Query Cache
1505− | RangeFilter FieldName RangeValue RangeExecution Cache
1506− | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
1507− | TermFilter Term Cache
1508− deriving (Eq, Read, Show, Generic, Typeable)
1509−
1510data ZeroTermsQuery = ZeroTermsNone
1494data ZeroTermsQuery = ZeroTermsNone
1511 | ZeroTermsAll deriving (Eq, Read, Show, Generic, Typeable)
1495 | ZeroTermsAll deriving (Eq, Read, Show, Generic, Typeable)
1512
1496
@@ -1713,8 +1697,7 @@ data Interval = Year
1713 | Day
1697 | Day
1714 | Hour
1698 | Hour
1715 | Minute
1699 | Minute
1716− | Second
1717− | FractionalInterval Float TimeInterval deriving (Eq, Read, Show, Generic, Typeable)
1700+ | Second deriving (Eq, Read, Show, Generic, Typeable)
1718
1701
1719data Aggregation = TermsAgg TermsAggregation
1702data Aggregation = TermsAgg TermsAggregation
1720 | CardinalityAgg CardinalityAggregation
1703 | CardinalityAgg CardinalityAggregation
@@ -1808,7 +1791,7 @@ mkCardinalityAggregation t = CardinalityAggregation t Nothing
1808instance ToJSON Version where
1791instance ToJSON Version where
1809 toJSON Version {..} = object ["number" .= number
1792 toJSON Version {..} = object ["number" .= number
1810 ,"build_hash" .= build_hash
1793 ,"build_hash" .= build_hash
1811− ,"build_timestamp" .= build_timestamp
1794+ ,"build_date" .= build_date
1812 ,"build_snapshot" .= build_snapshot
1795 ,"build_snapshot" .= build_snapshot
1813 ,"lucene_version" .= lucene_version]
1796 ,"lucene_version" .= lucene_version]
1814
1797
@@ -1817,7 +1800,7 @@ instance FromJSON Version where
1817 where parse o = Version
1800 where parse o = Version
1818 <$> o .: "number"
1801 <$> o .: "number"
1819 <*> o .: "build_hash"
1802 <*> o .: "build_hash"
1820− <*> o .: "build_timestamp"
1803+ <*> o .: "build_date"
1821 <*> o .: "build_snapshot"
1804 <*> o .: "build_snapshot"
1822 <*> o .: "lucene_version"
1805 <*> o .: "lucene_version"
1823
1806
@@ -1860,7 +1843,6 @@ instance ToJSON Interval where
1860 toJSON Hour = "hour"
1843 toJSON Hour = "hour"
1861 toJSON Minute = "minute"
1844 toJSON Minute = "minute"
1862 toJSON Second = "second"
1845 toJSON Second = "second"
1863− toJSON (FractionalInterval fraction interval) = toJSON $ show fraction ++ show interval
1864
1846
1865instance Show TimeInterval where
1847instance Show TimeInterval where
1866 show Weeks = "w"
1848 show Weeks = "w"
@@ -2058,193 +2040,6 @@ instance FromJSON POSIXMS where
2058 where parse n = let n' = truncate n :: Integer
2040 where parse n = let n' = truncate n :: Integer
2059 in POSIXMS (posixSecondsToUTCTime (fromInteger (n' `div` 1000)))
2041 in POSIXMS (posixSecondsToUTCTime (fromInteger (n' `div` 1000)))
2060
2042
2061−instance Monoid Filter where
2062− mempty = IdentityFilter
2063− mappend a b = AndFilter [a, b] defaultCache
2064−
2065−instance Seminearring Filter where
2066− a <||> b = OrFilter [a, b] defaultCache
2067−
2068−instance ToJSON Filter where
2069− toJSON (AndFilter filters cache) =
2070− object ["and" .=
2071− object [ "filters" .= fmap toJSON filters
2072− , "_cache" .= cache]]
2073−
2074− toJSON (OrFilter filters cache) =
2075− object ["or" .=
2076− object [ "filters" .= fmap toJSON filters
2077− , "_cache" .= cache]]
2078−
2079− toJSON (NotFilter notFilter cache) =
2080− object ["not" .=
2081− object ["filter" .= notFilter
2082− , "_cache" .= cache]]
2083−
2084− toJSON (IdentityFilter) =
2085− object ["match_all" .= object []]
2086−
2087− toJSON (TermFilter (Term termFilterField termFilterValue) cache) =
2088− object ["term" .= object base]
2089− where base = [termFilterField .= termFilterValue,
2090− "_cache" .= cache]
2091−
2092− toJSON (ExistsFilter (FieldName fieldName)) =
2093− object ["exists" .= object
2094− ["field" .= fieldName]]
2095−
2096− toJSON (BoolFilter boolMatch) =
2097− object ["bool" .= boolMatch]
2098−
2099− toJSON (GeoBoundingBoxFilter bbConstraint) =
2100− object ["geo_bounding_box" .= bbConstraint]
2101−
2102− toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) geoDistLatLon)
2103− distance distanceType optimizeBbox cache) =
2104− object ["geo_distance" .=
2105− object ["distance" .= distance
2106− , "distance_type" .= distanceType
2107− , "optimize_bbox" .= optimizeBbox
2108− , distanceGeoField .= geoDistLatLon
2109− , "_cache" .= cache]]
2110−
2111− toJSON (GeoDistanceRangeFilter (GeoPoint (FieldName gddrField) drLatLon)
2112− (DistanceRange geoDistRangeDistFrom drDistanceTo)) =
2113− object ["geo_distance_range" .=
2114− object ["from" .= geoDistRangeDistFrom
2115− , "to" .= drDistanceTo
2116− , gddrField .= drLatLon]]
2117−
2118− toJSON (GeoPolygonFilter (FieldName geoPolygonFilterField) latLons) =
2119− object ["geo_polygon" .=
2120− object [geoPolygonFilterField .=
2121− object ["points" .= fmap toJSON latLons]]]
2122−
2123− toJSON (IdsFilter (MappingName mappingName) values) =
2124− object ["ids" .=
2125− object ["type" .= mappingName
2126− , "values" .= fmap unpackId values]]
2127−
2128− toJSON (LimitFilter limit) =
2129− object ["limit" .= object ["value" .= limit]]
2130−
2131− toJSON (MissingFilter (FieldName fieldName) (Existence existence) (NullValue nullValue)) =
2132− object ["missing" .=
2133− object ["field" .= fieldName
2134− , "existence" .= existence
2135− , "null_value" .= nullValue]]
2136−
2137− toJSON (PrefixFilter (FieldName fieldName) fieldValue cache) =
2138− object ["prefix" .=
2139− object [fieldName .= fieldValue
2140− , "_cache" .= cache]]
2141−
2142− toJSON (QueryFilter query False) =
2143− object ["query" .= toJSON query ]
2144− toJSON (QueryFilter query True) =
2145− object ["fquery" .=
2146− object [ "query" .= toJSON query
2147− , "_cache" .= True ]]
2148−
2149− toJSON (RangeFilter (FieldName fieldName) rangeValue rangeExecution cache) =
2150− object ["range" .=
2151− object [ fieldName .= object (rangeValueToPair rangeValue)
2152− , "execution" .= rangeExecution
2153− , "_cache" .= cache]]
2154−
2155− toJSON (RegexpFilter (FieldName fieldName)
2156− (Regexp regexText) flags (CacheName cacheName) cache (CacheKey cacheKey)) =
2157− object ["regexp" .=
2158− object [fieldName .=
2159− object ["value" .= regexText
2160− , "flags" .= flags]
2161− , "_name" .= cacheName
2162− , "_cache" .= cache
2163− , "_cache_key" .= cacheKey]]
2164−
2165−instance FromJSON Filter where
2166− parseJSON = withObject "Filter" parse
2167− where parse o = andFilter `taggedWith` "and"
2168− <|> orFilter `taggedWith` "or"
2169− <|> notFilter `taggedWith` "not"
2170− <|> identityFilter `taggedWith` "match_all"
2171− <|> boolFilter `taggedWith` "bool"
2172− <|> existsFilter `taggedWith` "exists"
2173− <|> geoBoundingBoxFilter `taggedWith` "geo_bounding_box"
2174− <|> geoDistanceFilter `taggedWith` "geo_distance"
2175− <|> geoDistanceRangeFilter `taggedWith` "geo_distance_range"
2176− <|> geoPolygonFilter `taggedWith` "geo_polygon"
2177− <|> idsFilter `taggedWith` "ids"
2178− <|> limitFilter `taggedWith` "limit"
2179− <|> missingFilter `taggedWith` "missing"
2180− <|> prefixFilter `taggedWith` "prefix"
2181− <|> queryFilter `taggedWith` "query"
2182− <|> fqueryFilter `taggedWith` "fquery"
2183− <|> rangeFilter `taggedWith` "range"
2184− <|> regexpFilter `taggedWith` "regexp"
2185− <|> termFilter `taggedWith` "term"
2186− where taggedWith parser k = parser =<< o .: k
2187− andFilter o = AndFilter <$> o .: "filters"
2188− <*> o .:? "_cache" .!= defaultCache
2189− orFilter o = OrFilter <$> o .: "filters"
2190− <*> o .:? "_cache" .!= defaultCache
2191− notFilter o = NotFilter <$> o .: "filter"
2192− <*> o .: "_cache" .!= defaultCache
2193− identityFilter :: Object -> Parser Filter
2194− identityFilter m
2195− | HM.null m = pure IdentityFilter
2196− | otherwise = fail ("Identityfilter expected empty object but got " <> show m)
2197− boolFilter = pure . BoolFilter
2198− existsFilter o = ExistsFilter <$> o .: "field"
2199− geoBoundingBoxFilter = pure . GeoBoundingBoxFilter
2200− geoDistanceFilter o = do
2201− case HM.toList (deleteSeveral ["distance", "distance_type", "optimize_bbox", "_cache"] o) of
2202− [(fn, v)] -> do
2203− gp <- GeoPoint (FieldName fn) <$> parseJSON v
2204− GeoDistanceFilter gp <$> o .: "distance"
2205− <*> o .: "distance_type"
2206− <*> o .: "optimize_bbox"
2207− <*> o .:? "_cache" .!= defaultCache
2208− _ -> fail "Could not find GeoDistanceFilter field name"
2209− geoDistanceRangeFilter o = do
2210− case HM.toList (deleteSeveral ["from", "to"] o) of
2211− [(fn, v)] -> do
2212− gp <- GeoPoint (FieldName fn) <$> parseJSON v
2213− rng <- DistanceRange <$> o .: "from" <*> o .: "to"
2214− return (GeoDistanceRangeFilter gp rng)
2215− _ -> fail "Could not find GeoDistanceRangeFilter field name"
2216− geoPolygonFilter = fieldTagged $ \fn o -> GeoPolygonFilter fn <$> o .: "points"
2217− idsFilter o = IdsFilter <$> o .: "type"
2218− <*> o .: "values"
2219− limitFilter o = LimitFilter <$> o .: "value"
2220− missingFilter o = MissingFilter <$> o .: "field"
2221− <*> o .: "existence"
2222− <*> o .: "null_value"
2223− prefixFilter o = case HM.toList (HM.delete "_cache" o) of
2224− [(fn, String v)] -> PrefixFilter (FieldName fn) v <$> o .:? "_cache" .!= defaultCache
2225− _ -> fail "Could not parse PrefixFilter"
2226−
2227− queryFilter q = pure (QueryFilter q False)
2228− fqueryFilter o = QueryFilter <$> o .: "query" <*> pure True
2229− rangeFilter o = case HM.toList (deleteSeveral ["execution", "_cache"] o) of
2230− [(fn, v)] -> RangeFilter (FieldName fn)
2231− <$> parseJSON v
2232− <*> o .: "execution"
2233− <*> o .:? "_cache" .!= defaultCache
2234− _ -> fail "Could not find field name for RangeFilter"
2235− regexpFilter o = case HM.toList (deleteSeveral ["_name", "_cache", "_cache_key"] o) of
2236− [(fn, Object o')] -> RegexpFilter (FieldName fn)
2237− <$> o' .: "value"
2238− <*> o' .: "flags"
2239− <*> o .: "_name"
2240− <*> o .:? "_cache" .!= defaultCache
2241− <*> o .: "_cache_key"
2242− _ -> fail "Could not find field name for RegexpFilter"
2243− termFilter o = case HM.toList (HM.delete "_cache" o) of
2244− [(termField, String termVal)] -> TermFilter (Term termField termVal)
2245− <$> o .:? "_cache" .!= defaultCache
2246− _ -> fail "Could not find term field for TermFilter"
2247−
2248fieldTagged :: Monad m => (FieldName -> Object -> m a) -> Object -> m a
2043fieldTagged :: Monad m => (FieldName -> Object -> m a) -> Object -> m a
2249fieldTagged f o = case HM.toList o of
2044fieldTagged f o = case HM.toList o of
2250 [(k, Object o')] -> f (FieldName k) o'
2045 [(k, Object o')] -> f (FieldName k) o'
@@ -2291,10 +2086,6 @@ instance ToJSON Query where
2291 toJSON (QueryCommonTermsQuery commonTermsQuery) =
2086 toJSON (QueryCommonTermsQuery commonTermsQuery) =
2292 object [ "common" .= commonTermsQuery ]
2087 object [ "common" .= commonTermsQuery ]
2293
2088
2294− toJSON (ConstantScoreFilter csFilter boost) =
2295− object ["constant_score" .= object ["filter" .= csFilter
2296− , "boost" .= boost]]
2297−
2298 toJSON (ConstantScoreQuery query boost) =
2089 toJSON (ConstantScoreQuery query boost) =
2299 object ["constant_score" .= object ["query" .= query
2090 object ["constant_score" .= object ["query" .= query
2300 , "boost" .= boost]]
2091 , "boost" .= boost]]
@@ -2302,9 +2093,6 @@ instance ToJSON Query where
2302 toJSON (QueryDisMaxQuery disMaxQuery) =
2093 toJSON (QueryDisMaxQuery disMaxQuery) =
2303 object [ "dis_max" .= disMaxQuery ]
2094 object [ "dis_max" .= disMaxQuery ]
2304
2095
2305− toJSON (QueryFilteredQuery qFilteredQuery) =
2306− object [ "filtered" .= qFilteredQuery ]
2307−
2308 toJSON (QueryFuzzyLikeThisQuery fuzzyQuery) =
2096 toJSON (QueryFuzzyLikeThisQuery fuzzyQuery) =
2309 object [ "fuzzy_like_this" .= fuzzyQuery ]
2097 object [ "fuzzy_like_this" .= fuzzyQuery ]
2310
2098
@@ -2347,6 +2135,13 @@ instance ToJSON Query where
2347 toJSON (QuerySimpleQueryStringQuery query) =
2135 toJSON (QuerySimpleQueryStringQuery query) =
2348 object [ "simple_query_string" .= query ]
2136 object [ "simple_query_string" .= query ]
2349
2137
2138+ toJSON (QueryExistsQuery (FieldName fieldName)) =
2139+ object ["exists" .= object
2140+ ["field" .= fieldName]
2141+ ]
2142+ toJSON QueryMatchNoneQuery =
2143+ object ["match_none" .= object []]
2144+
2350instance FromJSON Query where
2145instance FromJSON Query where
2351 parseJSON v = withObject "Query" parse v
2146 parseJSON v = withObject "Query" parse v
2352 where parse o = termQuery `taggedWith` "term"
2147 where parse o = termQuery `taggedWith` "term"
@@ -2358,10 +2153,8 @@ instance FromJSON Query where
2358 <|> queryBoolQuery `taggedWith` "bool"
2153 <|> queryBoolQuery `taggedWith` "bool"
2359 <|> queryBoostingQuery `taggedWith` "boosting"
2154 <|> queryBoostingQuery `taggedWith` "boosting"
2360 <|> queryCommonTermsQuery `taggedWith` "common"
2155 <|> queryCommonTermsQuery `taggedWith` "common"
2361− <|> constantScoreFilter `taggedWith` "constant_score"
2362 <|> constantScoreQuery `taggedWith` "constant_score"
2156 <|> constantScoreQuery `taggedWith` "constant_score"
2363 <|> queryDisMaxQuery `taggedWith` "dis_max"
2157 <|> queryDisMaxQuery `taggedWith` "dis_max"
2364− <|> queryFilteredQuery `taggedWith` "filtered"
2365 <|> queryFuzzyLikeThisQuery `taggedWith` "fuzzy_like_this"
2158 <|> queryFuzzyLikeThisQuery `taggedWith` "fuzzy_like_this"
2366 <|> queryFuzzyLikeFieldQuery `taggedWith` "fuzzy_like_this_field"
2159 <|> queryFuzzyLikeFieldQuery `taggedWith` "fuzzy_like_this_field"
2367 <|> queryFuzzyQuery `taggedWith` "fuzzy"
2160 <|> queryFuzzyQuery `taggedWith` "fuzzy"
@@ -2393,16 +2186,11 @@ instance FromJSON Query where
2393 queryBoolQuery = pure . QueryBoolQuery
2186 queryBoolQuery = pure . QueryBoolQuery
2394 queryBoostingQuery = pure . QueryBoostingQuery
2187 queryBoostingQuery = pure . QueryBoostingQuery
2395 queryCommonTermsQuery = pure . QueryCommonTermsQuery
2188 queryCommonTermsQuery = pure . QueryCommonTermsQuery
2396− constantScoreFilter o = case HM.lookup "filter" o of
2397− Just x -> ConstantScoreFilter <$> parseJSON x
2398− <*> o .: "boost"
2399− _ -> fail "Does not appear to be a ConstantScoreFilter"
2400 constantScoreQuery o = case HM.lookup "query" o of
2189 constantScoreQuery o = case HM.lookup "query" o of
2401 Just x -> ConstantScoreQuery <$> parseJSON x
2190 Just x -> ConstantScoreQuery <$> parseJSON x
2402 <*> o .: "boost"
2191 <*> o .: "boost"
2403 _ -> fail "Does not appear to be a ConstantScoreQuery"
2192 _ -> fail "Does not appear to be a ConstantScoreQuery"
2404 queryDisMaxQuery = pure . QueryDisMaxQuery
2193 queryDisMaxQuery = pure . QueryDisMaxQuery
2405− queryFilteredQuery = pure . QueryFilteredQuery
2406 queryFuzzyLikeThisQuery = pure . QueryFuzzyLikeThisQuery
2194 queryFuzzyLikeThisQuery = pure . QueryFuzzyLikeThisQuery
2407 queryFuzzyLikeFieldQuery = pure . QueryFuzzyLikeFieldQuery
2195 queryFuzzyLikeFieldQuery = pure . QueryFuzzyLikeFieldQuery
2408 queryFuzzyQuery = pure . QueryFuzzyQuery
2196 queryFuzzyQuery = pure . QueryFuzzyQuery
@@ -2417,6 +2205,7 @@ instance FromJSON Query where
2417 queryRangeQuery = pure . QueryRangeQuery
2205 queryRangeQuery = pure . QueryRangeQuery
2418 queryRegexpQuery = pure . QueryRegexpQuery
2206 queryRegexpQuery = pure . QueryRegexpQuery
2419 querySimpleQueryStringQuery = pure . QuerySimpleQueryStringQuery
2207 querySimpleQueryStringQuery = pure . QuerySimpleQueryStringQuery
2208+ queryExistsQuery o = QueryExistsQuery <$> o .: "field"
2420
2209
2421
2210
2422omitNulls :: [(Text, Value)] -> Value
2211omitNulls :: [(Text, Value)] -> Value
@@ -2425,7 +2214,6 @@ omitNulls = object . filter notNull where
2425 notNull (_, Array a) = (not . V.null) a
2214 notNull (_, Array a) = (not . V.null) a
2426 notNull _ = True
2215 notNull _ = True
2427
2216
2428−
2429instance ToJSON SimpleQueryStringQuery where
2217instance ToJSON SimpleQueryStringQuery where
2430 toJSON SimpleQueryStringQuery {..} =
2218 toJSON SimpleQueryStringQuery {..} =
2431 omitNulls (base ++ maybeAdd)
2219 omitNulls (base ++ maybeAdd)
@@ -2814,17 +2602,6 @@ instance FromJSON FuzzyLikeThisQuery where
2814 <*> o .: "boost"
2602 <*> o .: "boost"
2815 <*> o .:? "analyzer"
2603 <*> o .:? "analyzer"
2816
2604
2817−instance ToJSON FilteredQuery where
2818− toJSON (FilteredQuery query fFilter) =
2819− object [ "query" .= query
2820− , "filter" .= fFilter ]
2821−
2822−instance FromJSON FilteredQuery where
2823− parseJSON = withObject "FilteredQuery" parse
2824− where parse o = FilteredQuery
2825− <$> o .: "query"
2826− <*> o .: "filter"
2827−
2828instance ToJSON DisMaxQuery where
2605instance ToJSON DisMaxQuery where
2829 toJSON (DisMaxQuery queries tiebreaker boost) =
2606 toJSON (DisMaxQuery queries tiebreaker boost) =
2830 omitNulls base
2607 omitNulls base
@@ -2896,9 +2673,10 @@ instance FromJSON BoostingQuery where
2896 <*> o .: "negative_boost"
2673 <*> o .: "negative_boost"
2897
2674
2898instance ToJSON BoolQuery where
2675instance ToJSON BoolQuery where
2899− toJSON (BoolQuery mustM notM shouldM bqMin boost disableCoord) =
2676+ toJSON (BoolQuery mustM filterM notM shouldM bqMin boost disableCoord) =
2900 omitNulls base
2677 omitNulls base
2901 where base = [ "must" .= mustM
2678 where base = [ "must" .= mustM
2679+ , "filter" .= filterM
2902 , "must_not" .= notM
2680 , "must_not" .= notM
2903 , "should" .= shouldM
2681 , "should" .= shouldM
2904 , "minimum_should_match" .= bqMin
2682 , "minimum_should_match" .= bqMin
@@ -2909,6 +2687,7 @@ instance FromJSON BoolQuery where
2909 parseJSON = withObject "BoolQuery" parse
2687 parseJSON = withObject "BoolQuery" parse
2910 where parse o = BoolQuery
2688 where parse o = BoolQuery
2911 <$> o .:? "must" .!= []
2689 <$> o .:? "must" .!= []
2690+ <*> o .:? "filter" .!= []
2912 <*> o .:? "must_not" .!= []
2691 <*> o .:? "must_not" .!= []
2913 <*> o .:? "should" .!= []
2692 <*> o .:? "should" .!= []
2914 <*> o .:? "minimum_should_match"
2693 <*> o .:? "minimum_should_match"
@@ -3023,9 +2802,9 @@ instance FromJSON MatchQueryType where
3023
2802
3024instance FromJSON Status where
2803instance FromJSON Status where
3025 parseJSON (Object v) = Status <$>
2804 parseJSON (Object v) = Status <$>
3026− v .:? "ok" <*>
3027− (v .:? "status" .!= 200) <*>
3028 v .: "name" <*>
2805 v .: "name" <*>
2806+ v .: "cluster_name" <*>
2807+ v .: "cluster_uuid" <*>
3029 v .: "version" <*>
2808 v .: "version" <*>
3030 v .: "tagline"
2809 v .: "tagline"
3031 parseJSON _ = empty
2810 parseJSON _ = empty
@@ -3355,9 +3134,8 @@ instance FromJSON SearchAliasRouting where
3355 where parse t = SearchAliasRouting <$> parseNEJSON (String <$> T.splitOn "," t)
3134 where parse t = SearchAliasRouting <$> parseNEJSON (String <$> T.splitOn "," t)
3356
3135
3357instance ToJSON Search where
3136instance ToJSON Search where
3358− toJSON (Search query sFilter sort searchAggs highlight sTrackSortScores sFrom sSize _ sFields sSource) =
3137+ toJSON (Search mquery sFilter sort searchAggs highlight sTrackSortScores sFrom sSize _ sFields sSource) =
3359− omitNulls [ "query" .= query
3138+ omitNulls [ "query" .= query'
3360− , "filter" .= sFilter
3361 , "sort" .= sort
3139 , "sort" .= sort
3362 , "aggregations" .= searchAggs
3140 , "aggregations" .= searchAggs
3363 , "highlight" .= highlight
3141 , "highlight" .= highlight
@@ -3366,12 +3144,15 @@ instance ToJSON Search where
3366 , "track_scores" .= sTrackSortScores
3144 , "track_scores" .= sTrackSortScores
3367 , "fields" .= sFields
3145 , "fields" .= sFields
3368 , "_source" .= sSource]
3146 , "_source" .= sSource]
3369−
3147+
3148+ where query' = case sFilter of
3149+ Nothing -> mquery
3150+ Just x -> Just . QueryBoolQuery $ mkBoolQuery (maybeToList mquery) [x] [] []
3370
3151
3371instance ToJSON Source where
3152instance ToJSON Source where
3372 toJSON NoSource = toJSON False
3153 toJSON NoSource = toJSON False
3373 toJSON (SourcePatterns patterns) = toJSON patterns
3154 toJSON (SourcePatterns patterns) = toJSON patterns
3374− toJSON (SourceIncludeExclude incl excl) = object [ "include" .= incl, "exclude" .= excl ]
3155+ toJSON (SourceIncludeExclude incl excl) = object [ "includes" .= incl, "excludes" .= excl ]
3375
3156
3376instance ToJSON PatternOrPatterns where
3157instance ToJSON PatternOrPatterns where
3377 toJSON (PopPattern pattern) = toJSON pattern
3158 toJSON (PopPattern pattern) = toJSON pattern
@@ -3480,7 +3261,7 @@ instance ToJSON SortSpec where
3480 dsSortMode dsMissingSort dsNestedFilter)) =
3261 dsSortMode dsMissingSort dsNestedFilter)) =
3481 object [dsSortFieldName .= omitNulls base] where
3262 object [dsSortFieldName .= omitNulls base] where
3482 base = [ "order" .= dsSortOrder
3263 base = [ "order" .= dsSortOrder
3483− , "ignore_unmapped" .= dsIgnoreUnmapped
3264+ , "unmapped_type" .= dsIgnoreUnmapped
3484 , "mode" .= dsSortMode
3265 , "mode" .= dsSortMode
3485 , "missing" .= dsMissingSort
3266 , "missing" .= dsMissingSort
3486 , "nested_filter" .= dsNestedFilter ]
3267 , "nested_filter" .= dsNestedFilter ]
@@ -3887,7 +3668,7 @@ data NodeStats = NodeStats {
3887 , nodeStatsHTTP :: NodeHTTPStats
3668 , nodeStatsHTTP :: NodeHTTPStats
3888 , nodeStatsTransport :: NodeTransportStats
3669 , nodeStatsTransport :: NodeTransportStats
3889 , nodeStatsFS :: NodeFSStats
3670 , nodeStatsFS :: NodeFSStats
3890− , nodeStatsNetwork :: NodeNetworkStats
3671+ , nodeStatsNetwork :: Maybe NodeNetworkStats
3891 , nodeStatsThreadPool :: NodeThreadPoolsStats
3672 , nodeStatsThreadPool :: NodeThreadPoolsStats
3892 , nodeStatsJVM :: NodeJVMStats
3673 , nodeStatsJVM :: NodeJVMStats
3893 , nodeStatsProcess :: NodeProcessStats
3674 , nodeStatsProcess :: NodeProcessStats
@@ -3940,7 +3721,7 @@ data NodeDataPathStats = NodeDataPathStats {
3940 , nodeDataPathFree :: Bytes
3721 , nodeDataPathFree :: Bytes
3941 , nodeDataPathTotal :: Bytes
3722 , nodeDataPathTotal :: Bytes
3942 , nodeDataPathType :: Maybe Text
3723 , nodeDataPathType :: Maybe Text
3943− , nodeDataPathDevice :: Text
3724+ , nodeDataPathDevice :: Maybe Text
3944 , nodeDataPathMount :: Text
3725 , nodeDataPathMount :: Text
3945 , nodeDataPathPath :: Text
3726 , nodeDataPathPath :: Text
3946 } deriving (Eq, Show, Generic, Typeable)
3727 } deriving (Eq, Show, Generic, Typeable)
@@ -3979,17 +3760,17 @@ data NodeThreadPoolsStats = NodeThreadPoolsStats {
3979 , nodeThreadPoolsStatsGet :: NodeThreadPoolStats
3760 , nodeThreadPoolsStatsGet :: NodeThreadPoolStats
3980 , nodeThreadPoolsStatsManagement :: NodeThreadPoolStats
3761 , nodeThreadPoolsStatsManagement :: NodeThreadPoolStats
3981 , nodeThreadPoolsStatsFetchShardStore :: Maybe NodeThreadPoolStats
3762 , nodeThreadPoolsStatsFetchShardStore :: Maybe NodeThreadPoolStats
3982− , nodeThreadPoolsStatsOptimize :: NodeThreadPoolStats
3763+ , nodeThreadPoolsStatsOptimize :: Maybe NodeThreadPoolStats
3983 , nodeThreadPoolsStatsFlush :: NodeThreadPoolStats
3764 , nodeThreadPoolsStatsFlush :: NodeThreadPoolStats
3984 , nodeThreadPoolsStatsSearch :: NodeThreadPoolStats
3765 , nodeThreadPoolsStatsSearch :: NodeThreadPoolStats
3985 , nodeThreadPoolsStatsWarmer :: NodeThreadPoolStats
3766 , nodeThreadPoolsStatsWarmer :: NodeThreadPoolStats
3986 , nodeThreadPoolsStatsGeneric :: NodeThreadPoolStats
3767 , nodeThreadPoolsStatsGeneric :: NodeThreadPoolStats
3987− , nodeThreadPoolsStatsSuggest :: NodeThreadPoolStats
3768+ , nodeThreadPoolsStatsSuggest :: Maybe NodeThreadPoolStats
3988 , nodeThreadPoolsStatsRefresh :: NodeThreadPoolStats
3769 , nodeThreadPoolsStatsRefresh :: NodeThreadPoolStats
3989 , nodeThreadPoolsStatsIndex :: NodeThreadPoolStats
3770 , nodeThreadPoolsStatsIndex :: NodeThreadPoolStats
3990 , nodeThreadPoolsStatsListener :: Maybe NodeThreadPoolStats
3771 , nodeThreadPoolsStatsListener :: Maybe NodeThreadPoolStats
3991 , nodeThreadPoolsStatsFetchShardStarted :: Maybe NodeThreadPoolStats
3772 , nodeThreadPoolsStatsFetchShardStarted :: Maybe NodeThreadPoolStats
3992− , nodeThreadPoolsStatsPercolate :: NodeThreadPoolStats
3773+ , nodeThreadPoolsStatsPercolate :: Maybe NodeThreadPoolStats
3993 } deriving (Eq, Show, Generic, Typeable)
3774 } deriving (Eq, Show, Generic, Typeable)
3994
3775
3995data NodeThreadPoolStats = NodeThreadPoolStats {
3776data NodeThreadPoolStats = NodeThreadPoolStats {
@@ -4040,34 +3821,26 @@ data JVMPoolStats = JVMPoolStats {
4040 } deriving (Eq, Show, Generic, Typeable)
3821 } deriving (Eq, Show, Generic, Typeable)
4041
3822
4042data NodeProcessStats = NodeProcessStats {
3823data NodeProcessStats = NodeProcessStats {
4043− nodeProcessMemTotalVirtual :: Bytes
3824+ nodeProcessTimestamp :: UTCTime
4044− , nodeProcessMemShare :: Bytes
4045− , nodeProcessMemResident :: Bytes
4046− , nodeProcessCPUTotal :: NominalDiffTime
4047− , nodeProcessCPUUser :: NominalDiffTime
4048− , nodeProcessCPUSys :: NominalDiffTime
4049− , nodeProcessCPUPercent :: Int
4050 , nodeProcessOpenFDs :: Int
3825 , nodeProcessOpenFDs :: Int
4051− , nodeProcessTimestamp :: UTCTime
3826+ , nodeProcessMaxFDs :: Int
3827+ , nodeProcessCPUPercent :: Int
3828+ , nodeProcessCPUTotal :: NominalDiffTime
3829+ , nodeProcessMemTotalVirtual :: Bytes
4052 } deriving (Eq, Show, Generic, Typeable)
3830 } deriving (Eq, Show, Generic, Typeable)
4053
3831
4054data NodeOSStats = NodeOSStats {
3832data NodeOSStats = NodeOSStats {
4055− nodeOSSwapFree :: Bytes
3833+ nodeOSTimestamp :: UTCTime
4056− , nodeOSSwapUsed :: Bytes
3834+ , nodeOSCPUPercent :: Int
4057− , nodeOSMemActualUsed :: Bytes
3835+ , nodeOSLoad :: Maybe LoadAvgs
4058− , nodeOSMemActualFree :: Bytes
3836+ , nodeOSMemTotal :: Bytes
4059− , nodeOSMemUsedPercent :: Int
3837+ , nodeOSMemFree :: Bytes
4060 , nodeOSMemFreePercent :: Int
3838 , nodeOSMemFreePercent :: Int
4061 , nodeOSMemUsed :: Bytes
3839 , nodeOSMemUsed :: Bytes
4062− , nodeOSMemFree :: Bytes
3840+ , nodeOSMemUsedPercent :: Int
4063− , nodeOSCPUStolen :: Int
3841+ , nodeOSSwapTotal :: Bytes
4064− , nodeOSCPUUsage :: Int
3842+ , nodeOSSwapFree :: Bytes
4065− , nodeOSCPUIdle :: Int
3843+ , nodeOSSwapUsed :: Bytes
4066− , nodeOSCPUUser :: Int
4067− , nodeOSCPUSys :: Int
4068− , nodeOSLoad :: Maybe LoadAvgs
4069− , nodeOSUptime :: NominalDiffTime
4070− , nodeOSTimestamp :: UTCTime
4071 } deriving (Eq, Show, Generic, Typeable)
3844 } deriving (Eq, Show, Generic, Typeable)
4072
3845
4073data LoadAvgs = LoadAvgs {
3846data LoadAvgs = LoadAvgs {
@@ -4084,9 +3857,9 @@ data NodeIndicesStats = NodeIndicesStats {
4084 , nodeIndicesStatsQueryCacheHits :: Maybe Int
3857 , nodeIndicesStatsQueryCacheHits :: Maybe Int
4085 , nodeIndicesStatsQueryCacheEvictions :: Maybe Int
3858 , nodeIndicesStatsQueryCacheEvictions :: Maybe Int
4086 , nodeIndicesStatsQueryCacheSize :: Maybe Bytes
3859 , nodeIndicesStatsQueryCacheSize :: Maybe Bytes
4087− , nodeIndicesStatsSuggestCurrent :: Int
3860+ , nodeIndicesStatsSuggestCurrent :: Maybe Int
4088− , nodeIndicesStatsSuggestTime :: NominalDiffTime
3861+ , nodeIndicesStatsSuggestTime :: Maybe NominalDiffTime
4089− , nodeIndicesStatsSuggestTotal :: Int
3862+ , nodeIndicesStatsSuggestTotal :: Maybe Int
4090 , nodeIndicesStatsTranslogSize :: Bytes
3863 , nodeIndicesStatsTranslogSize :: Bytes
4091 , nodeIndicesStatsTranslogOps :: Int
3864 , nodeIndicesStatsTranslogOps :: Int
4092 , nodeIndicesStatsSegFixedBitSetMemory :: Maybe Bytes
3865 , nodeIndicesStatsSegFixedBitSetMemory :: Maybe Bytes
@@ -4096,16 +3869,13 @@ data NodeIndicesStats = NodeIndicesStats {
4096 , nodeIndicesStatsSegMemory :: Bytes
3869 , nodeIndicesStatsSegMemory :: Bytes
4097 , nodeIndicesStatsSegCount :: Int
3870 , nodeIndicesStatsSegCount :: Int
4098 , nodeIndicesStatsCompletionSize :: Bytes
3871 , nodeIndicesStatsCompletionSize :: Bytes
4099− , nodeIndicesStatsPercolateQueries :: Int
3872+ , nodeIndicesStatsPercolateQueries :: Maybe Int
4100− , nodeIndicesStatsPercolateMemory :: Bytes
3873+ , nodeIndicesStatsPercolateMemory :: Maybe Bytes
4101− , nodeIndicesStatsPercolateCurrent :: Int
3874+ , nodeIndicesStatsPercolateCurrent :: Maybe Int
4102− , nodeIndicesStatsPercolateTime :: NominalDiffTime
3875+ , nodeIndicesStatsPercolateTime :: Maybe NominalDiffTime
4103− , nodeIndicesStatsPercolateTotal :: Int
3876+ , nodeIndicesStatsPercolateTotal :: Maybe Int
4104 , nodeIndicesStatsFieldDataEvictions :: Int
3877 , nodeIndicesStatsFieldDataEvictions :: Int
4105 , nodeIndicesStatsFieldDataMemory :: Bytes
3878 , nodeIndicesStatsFieldDataMemory :: Bytes
4106− , nodeIndicesStatsIDCacheMemory :: Bytes
4107− , nodeIndicesStatsFilterCacheEvictions :: Int
4108− , nodeIndicesStatsFilterCacheMemory :: Bytes
4109 , nodeIndicesStatsWarmerTotalTime :: NominalDiffTime
3879 , nodeIndicesStatsWarmerTotalTime :: NominalDiffTime
4110 , nodeIndicesStatsWarmerTotal :: Int
3880 , nodeIndicesStatsWarmerTotal :: Int
4111 , nodeIndicesStatsWarmerCurrent :: Int
3881 , nodeIndicesStatsWarmerCurrent :: Int
@@ -4163,7 +3933,7 @@ newtype PluginName = PluginName { pluginName :: Text }
4163 deriving (Eq, Ord, Generic, Show, Typeable, FromJSON)
3933 deriving (Eq, Ord, Generic, Show, Typeable, FromJSON)
4164
3934
4165data NodeInfo = NodeInfo {
3935data NodeInfo = NodeInfo {
4166− nodeInfoHTTPAddress :: EsAddress
3936+ nodeInfoHTTPAddress :: Maybe EsAddress
4167 , nodeInfoBuild :: BuildHash
3937 , nodeInfoBuild :: BuildHash
4168 , nodeInfoESVersion :: VersionNumber
3938 , nodeInfoESVersion :: VersionNumber
4169 , nodeInfoIP :: Server
3939 , nodeInfoIP :: Server
@@ -4174,7 +3944,7 @@ data NodeInfo = NodeInfo {
4174 , nodeInfoPlugins :: [NodePluginInfo]
3944 , nodeInfoPlugins :: [NodePluginInfo]
4175 , nodeInfoHTTP :: NodeHTTPInfo
3945 , nodeInfoHTTP :: NodeHTTPInfo
4176 , nodeInfoTransport :: NodeTransportInfo
3946 , nodeInfoTransport :: NodeTransportInfo
4177− , nodeInfoNetwork :: NodeNetworkInfo
3947+ , nodeInfoNetwork :: Maybe NodeNetworkInfo
4178 , nodeInfoThreadPool :: NodeThreadPoolsInfo
3948 , nodeInfoThreadPool :: NodeThreadPoolsInfo
4179 , nodeInfoJVM :: NodeJVMInfo
3949 , nodeInfoJVM :: NodeJVMInfo
4180 , nodeInfoProcess :: NodeProcessInfo
3950 , nodeInfoProcess :: NodeProcessInfo
@@ -4206,7 +3976,7 @@ data NodeTransportInfo = NodeTransportInfo {
4206
3976
4207data BoundTransportAddress = BoundTransportAddress {
3977data BoundTransportAddress = BoundTransportAddress {
4208 publishAddress :: EsAddress
3978 publishAddress :: EsAddress
4209− , boundAddress :: EsAddress
3979+ , boundAddress :: [EsAddress]
4210 } deriving (Eq, Show, Generic, Typeable)
3980 } deriving (Eq, Show, Generic, Typeable)
4211
3981
4212data NodeNetworkInfo = NodeNetworkInfo {
3982data NodeNetworkInfo = NodeNetworkInfo {
@@ -4229,15 +3999,15 @@ data NodeNetworkInterface = NodeNetworkInterface {
4229data NodeThreadPoolsInfo = NodeThreadPoolsInfo {
3999data NodeThreadPoolsInfo = NodeThreadPoolsInfo {
4230 nodeThreadPoolsRefresh :: NodeThreadPoolInfo
4000 nodeThreadPoolsRefresh :: NodeThreadPoolInfo
4231 , nodeThreadPoolsManagement :: NodeThreadPoolInfo
4001 , nodeThreadPoolsManagement :: NodeThreadPoolInfo
4232− , nodeThreadPoolsPercolate :: NodeThreadPoolInfo
4002+ , nodeThreadPoolsPercolate :: Maybe NodeThreadPoolInfo
4233 , nodeThreadPoolsListener :: Maybe NodeThreadPoolInfo
4003 , nodeThreadPoolsListener :: Maybe NodeThreadPoolInfo
4234 , nodeThreadPoolsFetchShardStarted :: Maybe NodeThreadPoolInfo
4004 , nodeThreadPoolsFetchShardStarted :: Maybe NodeThreadPoolInfo
4235 , nodeThreadPoolsSearch :: NodeThreadPoolInfo
4005 , nodeThreadPoolsSearch :: NodeThreadPoolInfo
4236 , nodeThreadPoolsFlush :: NodeThreadPoolInfo
4006 , nodeThreadPoolsFlush :: NodeThreadPoolInfo
4237 , nodeThreadPoolsWarmer :: NodeThreadPoolInfo
4007 , nodeThreadPoolsWarmer :: NodeThreadPoolInfo
4238− , nodeThreadPoolsOptimize :: NodeThreadPoolInfo
4008+ , nodeThreadPoolsOptimize :: Maybe NodeThreadPoolInfo
4239 , nodeThreadPoolsBulk :: NodeThreadPoolInfo
4009 , nodeThreadPoolsBulk :: NodeThreadPoolInfo
4240− , nodeThreadPoolsSuggest :: NodeThreadPoolInfo
4010+ , nodeThreadPoolsSuggest :: Maybe NodeThreadPoolInfo
4241 , nodeThreadPoolsMerge :: NodeThreadPoolInfo
4011 , nodeThreadPoolsMerge :: NodeThreadPoolInfo
4242 , nodeThreadPoolsSnapshot :: NodeThreadPoolInfo
4012 , nodeThreadPoolsSnapshot :: NodeThreadPoolInfo
4243 , nodeThreadPoolsGet :: NodeThreadPoolInfo
4013 , nodeThreadPoolsGet :: NodeThreadPoolInfo
@@ -4300,11 +4070,12 @@ newtype PID = PID {
4300 } deriving (Eq, Show, Generic, Typeable, FromJSON)
4070 } deriving (Eq, Show, Generic, Typeable, FromJSON)
4301
4071
4302data NodeOSInfo = NodeOSInfo {
4072data NodeOSInfo = NodeOSInfo {
4303− nodeOSSwap :: Bytes
4073+ nodeOSRefreshInterval :: NominalDiffTime
4304− , nodeOSMem :: Bytes
4074+ , nodeOSName :: Text
4305− , nodeOSCPUInfo :: CPUInfo
4075+ , nodeOSArch :: Text
4076+ , nodeOSVersion :: VersionNumber
4306 , nodeOSAvailableProcessors :: Int
4077 , nodeOSAvailableProcessors :: Int
4307− , nodeOSRefreshInterval :: NominalDiffTime
4078+ , nodeOSAllocatedProcessors :: Int
4308 } deriving (Eq, Show, Generic, Typeable)
4079 } deriving (Eq, Show, Generic, Typeable)
4309
4080
4310data CPUInfo = CPUInfo {
4081data CPUInfo = CPUInfo {
@@ -4320,7 +4091,7 @@ data CPUInfo = CPUInfo {
4320data NodeProcessInfo = NodeProcessInfo {
4091data NodeProcessInfo = NodeProcessInfo {
4321 nodeProcessMLockAll :: Bool
4092 nodeProcessMLockAll :: Bool
4322 -- ^ See <https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
4093 -- ^ See <https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
4323− , nodeProcessMaxFileDescriptors :: Int
4094+ , nodeProcessMaxFileDescriptors :: Maybe Int
4324 , nodeProcessId :: PID
4095 , nodeProcessId :: PID
4325 , nodeProcessRefreshInterval :: NominalDiffTime
4096 , nodeProcessRefreshInterval :: NominalDiffTime
4326 } deriving (Eq, Show, Generic, Typeable)
4097 } deriving (Eq, Show, Generic, Typeable)
@@ -4725,7 +4496,7 @@ instance FromJSON NodeDataPathStats where
4725 <*> o .: "free_in_bytes"
4496 <*> o .: "free_in_bytes"
4726 <*> o .: "total_in_bytes"
4497 <*> o .: "total_in_bytes"
4727 <*> o .:? "type"
4498 <*> o .:? "type"
4728− <*> o .: "dev"
4499+ <*> o .:? "dev"
4729 <*> o .: "mount"
4500 <*> o .: "mount"
4730 <*> o .: "path"
4501 <*> o .: "path"
4731
4502
@@ -4772,21 +4543,21 @@ instance FromJSON NodeThreadPoolsStats where
4772 where
4543 where
4773 parse o = NodeThreadPoolsStats <$> o .: "snapshot"
4544 parse o = NodeThreadPoolsStats <$> o .: "snapshot"
4774 <*> o .: "bulk"
4545 <*> o .: "bulk"
4775− <*> o .: "merge"
4546+ <*> o .: "force_merge"
4776 <*> o .: "get"
4547 <*> o .: "get"
4777 <*> o .: "management"
4548 <*> o .: "management"
4778 <*> o .:? "fetch_shard_store"
4549 <*> o .:? "fetch_shard_store"
4779− <*> o .: "optimize"
4550+ <*> o .:? "optimize"
4780 <*> o .: "flush"
4551 <*> o .: "flush"
4781 <*> o .: "search"
4552 <*> o .: "search"
4782 <*> o .: "warmer"
4553 <*> o .: "warmer"
4783 <*> o .: "generic"
4554 <*> o .: "generic"
4784− <*> o .: "suggest"
4555+ <*> o .:? "suggest"
4785 <*> o .: "refresh"
4556 <*> o .: "refresh"
4786 <*> o .: "index"
4557 <*> o .: "index"
4787 <*> o .:? "listener"
4558 <*> o .:? "listener"
4788 <*> o .:? "fetch_shard_started"
4559 <*> o .:? "fetch_shard_started"
4789− <*> o .: "percolate"
4560+ <*> o .:? "percolate"
4790instance FromJSON NodeThreadPoolStats where
4561instance FromJSON NodeThreadPoolStats where
4791 parseJSON = withObject "NodeThreadPoolStats" parse
4562 parseJSON = withObject "NodeThreadPoolStats" parse
4792 where
4563 where
@@ -4859,15 +4630,12 @@ instance FromJSON NodeProcessStats where
4859 parse o = do
4630 parse o = do
4860 mem <- o .: "mem"
4631 mem <- o .: "mem"
4861 cpu <- o .: "cpu"
4632 cpu <- o .: "cpu"
4862− NodeProcessStats <$> mem .: "total_virtual_in_bytes"
4633+ NodeProcessStats <$> (posixMS <$> o .: "timestamp")
4863− <*> mem .: "share_in_bytes"
4864− <*> mem .: "resident_in_bytes"
4865− <*> (unMS <$> cpu .: "total_in_millis")
4866− <*> (unMS <$> cpu .: "user_in_millis")
4867− <*> (unMS <$> cpu .: "sys_in_millis")
4868− <*> cpu .: "percent"
4869 <*> o .: "open_file_descriptors"
4634 <*> o .: "open_file_descriptors"
4870− <*> (posixMS <$> o .: "timestamp")
4635+ <*> o .: "max_file_descriptors"
4636+ <*> cpu .: "percent"
4637+ <*> (unMS <$> cpu .: "total_in_millis")
4638+ <*> mem .: "total_virtual_in_bytes"
4871
4639
4872instance FromJSON NodeOSStats where
4640instance FromJSON NodeOSStats where
4873 parseJSON = withObject "NodeOSStats" parse
4641 parseJSON = withObject "NodeOSStats" parse
@@ -4877,22 +4645,17 @@ instance FromJSON NodeOSStats where
4877 mem <- o .: "mem"
4645 mem <- o .: "mem"
4878 cpu <- o .: "cpu"
4646 cpu <- o .: "cpu"
4879 load <- o .:? "load_average"
4647 load <- o .:? "load_average"
4648+ NodeOSStats <$> (posixMS <$> o .: "timestamp")
4649+ <*> cpu .: "percent"
4650+ <*> pure load
4651+ <*> mem .: "total_in_bytes"
4880− NodeOSStats <$> swap .: "free_in_bytes"
4652+ <*> mem .: "free_in_bytes"
4881− <*> swap .: "used_in_bytes"
4882− <*> mem .: "actual_used_in_bytes"
4883− <*> mem .: "actual_free_in_bytes"
4884− <*> mem .: "used_percent"
4885 <*> mem .: "free_percent"
4653 <*> mem .: "free_percent"
4886 <*> mem .: "used_in_bytes"
4654 <*> mem .: "used_in_bytes"
4655+ <*> mem .: "used_percent"
4656+ <*> swap .: "total_in_bytes"
4887− <*> mem .: "free_in_bytes"
4657+ <*> swap .: "free_in_bytes"
4888− <*> cpu .: "stolen"
4658+ <*> swap .: "used_in_bytes"
4889− <*> cpu .: "usage"
4890− <*> cpu .: "idle"
4891− <*> cpu .: "user"
4892− <*> cpu .: "sys"
4893− <*> pure load
4894− <*> (unMS <$> o .: "uptime_in_millis")
4895− <*> (posixMS <$> o .: "timestamp")
4896
4659
4897instance FromJSON LoadAvgs where
4660instance FromJSON LoadAvgs where
4898 parseJSON = withArray "LoadAvgs" parse
4661 parseJSON = withArray "LoadAvgs" parse
@@ -4912,14 +4675,12 @@ instance FromJSON NodeIndicesStats where
4912 Nothing -> pure Nothing
4675 Nothing -> pure Nothing
4913 mRecovery <- o .:? "recovery"
4676 mRecovery <- o .:? "recovery"
4914 mQueryCache <- o .:? "query_cache"
4677 mQueryCache <- o .:? "query_cache"
4915− suggest <- o .: "suggest"
4678+ mSuggest <- o .:? "suggest"
4916 translog <- o .: "translog"
4679 translog <- o .: "translog"
4917 segments <- o .: "segments"
4680 segments <- o .: "segments"
4918 completion <- o .: "completion"
4681 completion <- o .: "completion"
4919− percolate <- o .: "percolate"
4682+ mPercolate <- o .:? "percolate"
4920 fielddata <- o .: "fielddata"
4683 fielddata <- o .: "fielddata"
4921− idCache <- o .: "id_cache"
4922− filterCache <- o .: "filter_cache"
4923 warmer <- o .: "warmer"
4684 warmer <- o .: "warmer"
4924 flush <- o .: "flush"
4685 flush <- o .: "flush"
4925 refresh <- o .: "refresh"
4686 refresh <- o .: "refresh"
@@ -4936,9 +4697,9 @@ instance FromJSON NodeIndicesStats where
4936 <*> mQueryCache .:: "hit_count"
4697 <*> mQueryCache .:: "hit_count"
4937 <*> mQueryCache .:: "evictions"
4698 <*> mQueryCache .:: "evictions"
4938 <*> mQueryCache .:: "memory_size_in_bytes"
4699 <*> mQueryCache .:: "memory_size_in_bytes"
4939− <*> suggest .: "current"
4700+ <*> mSuggest .:: "current"
4940− <*> (unMS <$> suggest .: "time_in_millis")
4701+ <*> (fmap unMS <$> mSuggest .:: "time_in_millis")
4941− <*> suggest .: "total"
4702+ <*> mSuggest .:: "total"
4942 <*> translog .: "size_in_bytes"
4703 <*> translog .: "size_in_bytes"
4943 <*> translog .: "operations"
4704 <*> translog .: "operations"
4944 <*> segments .:? "fixed_bit_set_memory_in_bytes"
4705 <*> segments .:? "fixed_bit_set_memory_in_bytes"
@@ -4948,16 +4709,13 @@ instance FromJSON NodeIndicesStats where
4948 <*> segments .: "memory_in_bytes"
4709 <*> segments .: "memory_in_bytes"
4949 <*> segments .: "count"
4710 <*> segments .: "count"
4950 <*> completion .: "size_in_bytes"
4711 <*> completion .: "size_in_bytes"
4951− <*> percolate .: "queries"
4712+ <*> mPercolate .:: "queries"
4952− <*> percolate .: "memory_size_in_bytes"
4713+ <*> mPercolate .:: "memory_size_in_bytes"
4953− <*> percolate .: "current"
4714+ <*> mPercolate .:: "current"
4954− <*> (unMS <$> percolate .: "time_in_millis")
4715+ <*> (fmap unMS <$> mPercolate .:: "time_in_millis")
4955− <*> percolate .: "total"
4716+ <*> mPercolate .:: "total"
4956 <*> fielddata .: "evictions"
4717 <*> fielddata .: "evictions"
4957 <*> fielddata .: "memory_size_in_bytes"
4718 <*> fielddata .: "memory_size_in_bytes"
4958− <*> idCache .: "memory_size_in_bytes"
4959− <*> filterCache .: "evictions"
4960− <*> filterCache .: "memory_size_in_bytes"
4961 <*> (unMS <$> warmer .: "total_time_in_millis")
4719 <*> (unMS <$> warmer .: "total_time_in_millis")
4962 <*> warmer .: "total"
4720 <*> warmer .: "total"
4963 <*> warmer .: "current"
4721 <*> warmer .: "current"
@@ -5015,7 +4773,7 @@ parseNodeStats fnid o = do
5015 <*> o .: "http"
4773 <*> o .: "http"
5016 <*> o .: "transport"
4774 <*> o .: "transport"
5017 <*> o .: "fs"
4775 <*> o .: "fs"
5018− <*> o .: "network"
4776+ <*> o .:? "network"
5019 <*> o .: "thread_pool"
4777 <*> o .: "thread_pool"
5020 <*> o .: "jvm"
4778 <*> o .: "jvm"
5021 <*> o .: "process"
4779 <*> o .: "process"
@@ -5024,8 +4782,8 @@ parseNodeStats fnid o = do
5024
4782
5025parseNodeInfo :: FullNodeId -> Object -> Parser NodeInfo
4783parseNodeInfo :: FullNodeId -> Object -> Parser NodeInfo
5026parseNodeInfo nid o =
4784parseNodeInfo nid o =
5027− NodeInfo <$> o .: "http_address"
4785+ NodeInfo <$> o .:? "http_address"
5028− <*> o .: "build"
4786+ <*> o .: "build_hash"
5029 <*> o .: "version"
4787 <*> o .: "version"
5030 <*> o .: "ip"
4788 <*> o .: "ip"
5031 <*> o .: "host"
4789 <*> o .: "host"
@@ -5035,7 +4793,7 @@ parseNodeInfo nid o =
5035 <*> o .: "plugins"
4793 <*> o .: "plugins"
5036 <*> o .: "http"
4794 <*> o .: "http"
5037 <*> o .: "transport"
4795 <*> o .: "transport"
5038− <*> o .: "network"
4796+ <*> o .:? "network"
5039 <*> o .: "thread_pool"
4797 <*> o .: "thread_pool"
5040 <*> o .: "jvm"
4798 <*> o .: "jvm"
5041 <*> o .: "process"
4799 <*> o .: "process"
@@ -5067,13 +4825,12 @@ instance FromJSON NodeOSInfo where
5067 parseJSON = withObject "NodeOSInfo" parse
4825 parseJSON = withObject "NodeOSInfo" parse
5068 where
4826 where
5069 parse o = do
4827 parse o = do
5070− swap <- o .: "swap"
4828+ NodeOSInfo <$> (unMS <$> o .: "refresh_interval_in_millis")
5071− mem <- o .: "mem"
4829+ <*> o .: "name"
5072− NodeOSInfo <$> swap .: "total_in_bytes"
4830+ <*> o .: "arch"
5073− <*> mem .: "total_in_bytes"
4831+ <*> o .: "version"
5074− <*> o .: "cpu"
5075 <*> o .: "available_processors"
4832 <*> o .: "available_processors"
5076− <*> (unMS <$> o .: "refresh_interval_in_millis")
4833+ <*> o .: "allocated_processors"
5077
4834
5078
4835
5079instance FromJSON CPUInfo where
4836instance FromJSON CPUInfo where
@@ -5091,7 +4848,7 @@ instance FromJSON NodeProcessInfo where
5091 parseJSON = withObject "NodeProcessInfo" parse
4848 parseJSON = withObject "NodeProcessInfo" parse
5092 where
4849 where
5093 parse o = NodeProcessInfo <$> o .: "mlockall"
4850 parse o = NodeProcessInfo <$> o .: "mlockall"
5094− <*> o .: "max_file_descriptors"
4851+ <*> o .:? "max_file_descriptors"
5095 <*> o .: "id"
4852 <*> o .: "id"
5096 <*> (unMS <$> o .: "refresh_interval_in_millis")
4853 <*> (unMS <$> o .: "refresh_interval_in_millis")
5097
4854
@@ -5127,16 +4884,16 @@ instance FromJSON NodeThreadPoolsInfo where
5127 where
4884 where
5128 parse o = NodeThreadPoolsInfo <$> o .: "refresh"
4885 parse o = NodeThreadPoolsInfo <$> o .: "refresh"
5129 <*> o .: "management"
4886 <*> o .: "management"
5130− <*> o .: "percolate"
4887+ <*> o .:? "percolate"
5131 <*> o .:? "listener"
4888 <*> o .:? "listener"
5132 <*> o .:? "fetch_shard_started"
4889 <*> o .:? "fetch_shard_started"
5133 <*> o .: "search"
4890 <*> o .: "search"
5134 <*> o .: "flush"
4891 <*> o .: "flush"
5135 <*> o .: "warmer"
4892 <*> o .: "warmer"
5136− <*> o .: "optimize"
4893+ <*> o .:? "optimize"
5137 <*> o .: "bulk"
4894 <*> o .: "bulk"
5138− <*> o .: "suggest"
4895+ <*> o .:? "suggest"
5139− <*> o .: "merge"
4896+ <*> o .: "force_merge"
5140 <*> o .: "snapshot"
4897 <*> o .: "snapshot"
5141 <*> o .: "get"
4898 <*> o .: "get"
5142 <*> o .:? "fetch_shard_store"
4899 <*> o .:? "fetch_shard_store"
stack-8.0.yamldeleted−15
@@ -1,15 +0,0 @@
1−flags: {}
2−packages:
3−- '.'
4−extra-deps:
5−- quickcheck-properties-0.1
6−
7−# - http-client-0.5.0
8−# - fail-4.9.0.0
9−# - http-types-0.9
10−# - attoparsec-0.13.0.1
11−# - doctest-0.10.1
12−# - semigroups-0.18.0.1
13−# - uri-bytestring-0.1.9
14−# - temporary-resourcet-0.1.0.0
15−resolver: nightly-2016-08-20
stack.yaml+15−1
@@ -1 +1,15 @@
1−stack-7.10.yaml
1+flags: {}
2+packages:
3+- '.'
4+extra-deps:
5+- quickcheck-properties-0.1
6+
7+# - http-client-0.5.0
8+# - fail-4.9.0.0
9+# - http-types-0.9
10+# - attoparsec-0.13.0.1
11+# - doctest-0.10.1
12+# - semigroups-0.18.0.1
13+# - uri-bytestring-0.1.9
14+# - temporary-resourcet-0.1.0.0
15+resolver: nightly-2016-08-20
tests/tests.hs+35−259
@@ -47,7 +47,7 @@ import qualified Network.HTTP.Types.Status as NHTS
47import qualified Network.URI as URI
47import qualified Network.URI as URI
48import Prelude hiding (filter)
48import Prelude hiding (filter)
49import System.IO.Temp
49import System.IO.Temp
50−import System.Posix.Files
50+import System.PosixCompat.Files
51import Test.Hspec
51import Test.Hspec
52import Test.QuickCheck.Property.Monoid (T (..), eq, prop_Monoid)
52import Test.QuickCheck.Property.Monoid (T (..), eq, prop_Monoid)
53
53
@@ -100,6 +100,9 @@ es16 = Vers.Version [1, 6, 0] []
100es20 :: Vers.Version
100es20 :: Vers.Version
101es20 = Vers.Version [2, 0, 0] []
101es20 = Vers.Version [2, 0, 0] []
102
102
103+es50 :: Vers.Version
104+es50 = Vers.Version [5, 0, 0] []
105+
103getServerVersion :: IO (Maybe Vers.Version)
106getServerVersion :: IO (Maybe Vers.Version)
104getServerVersion = fmap extractVersion <$> withTestEnv getStatus
107getServerVersion = fmap extractVersion <$> withTestEnv getStatus
105 where
108 where
@@ -179,13 +182,16 @@ data ParentMapping = ParentMapping deriving (Eq, Show)
179instance ToJSON ParentMapping where
182instance ToJSON ParentMapping where
180 toJSON ParentMapping =
183 toJSON ParentMapping =
181 object ["properties" .=
184 object ["properties" .=
182− object [ "user" .= object ["type" .= ("string" :: Text)]
185+ object [ "user" .= object ["type" .= ("string" :: Text)
186+ , "fielddata" .= True
187+ ]
183 -- Serializing the date as a date is breaking other tests, mysteriously.
188 -- Serializing the date as a date is breaking other tests, mysteriously.
184 -- , "postDate" .= object [ "type" .= ("date" :: Text)
189 -- , "postDate" .= object [ "type" .= ("date" :: Text)
185 -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
190 -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
186 , "message" .= object ["type" .= ("string" :: Text)]
191 , "message" .= object ["type" .= ("string" :: Text)]
187 , "age" .= object ["type" .= ("integer" :: Text)]
192 , "age" .= object ["type" .= ("integer" :: Text)]
188 , "location" .= object ["type" .= ("geo_point" :: Text)]
193 , "location" .= object ["type" .= ("geo_point" :: Text)]
194+ , "extra" .= object ["type" .= ("keyword" :: Text)]
189 ]]
195 ]]
190
196
191data ChildMapping = ChildMapping deriving (Eq, Show)
197data ChildMapping = ChildMapping deriving (Eq, Show)
@@ -194,28 +200,35 @@ instance ToJSON ChildMapping where
194 toJSON ChildMapping =
200 toJSON ChildMapping =
195 object ["_parent" .= object ["type" .= ("parent" :: Text)]
201 object ["_parent" .= object ["type" .= ("parent" :: Text)]
196 , "properties" .=
202 , "properties" .=
197− object [ "user" .= object ["type" .= ("string" :: Text)]
203+ object [ "user" .= object ["type" .= ("string" :: Text)
204+ , "fielddata" .= True
205+ ]
198 -- Serializing the date as a date is breaking other tests, mysteriously.
206 -- Serializing the date as a date is breaking other tests, mysteriously.
199 -- , "postDate" .= object [ "type" .= ("date" :: Text)
207 -- , "postDate" .= object [ "type" .= ("date" :: Text)
200 -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
208 -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
201 , "message" .= object ["type" .= ("string" :: Text)]
209 , "message" .= object ["type" .= ("string" :: Text)]
202 , "age" .= object ["type" .= ("integer" :: Text)]
210 , "age" .= object ["type" .= ("integer" :: Text)]
203 , "location" .= object ["type" .= ("geo_point" :: Text)]
211 , "location" .= object ["type" .= ("geo_point" :: Text)]
212+ , "extra" .= object ["type" .= ("keyword" :: Text)]
204 ]]
213 ]]
205
214
206data TweetMapping = TweetMapping deriving (Eq, Show)
215data TweetMapping = TweetMapping deriving (Eq, Show)
207
216
208instance ToJSON TweetMapping where
217instance ToJSON TweetMapping where
209 toJSON TweetMapping =
218 toJSON TweetMapping =
219+ object ["tweet" .=
210− object ["properties" .=
220+ object ["properties" .=
211− object [ "user" .= object ["type" .= ("string" :: Text)]
221+ object [ "user" .= object [ "type" .= ("string" :: Text)
222+ , "fielddata" .= True
223+ ]
212− -- Serializing the date as a date is breaking other tests, mysteriously.
224+ -- Serializing the date as a date is breaking other tests, mysteriously.
213− -- , "postDate" .= object [ "type" .= ("date" :: Text)
225+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
214− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
226+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
215− , "message" .= object ["type" .= ("string" :: Text)]
227+ , "message" .= object ["type" .= ("string" :: Text)]
216− , "age" .= object ["type" .= ("integer" :: Text)]
228+ , "age" .= object ["type" .= ("integer" :: Text)]
217− , "location" .= object ["type" .= ("geo_point" :: Text)]
229+ , "location" .= object ["type" .= ("geo_point" :: Text)]
230+ , "extra" .= object ["type" .= ("keyword" :: Text)]
218− ]]
231+ ]]]
219
232
220exampleTweet :: Tweet
233exampleTweet :: Tweet
221exampleTweet = Tweet { user = "bitemyapp"
234exampleTweet = Tweet { user = "bitemyapp"
@@ -543,7 +556,6 @@ instance ApproxEq HasChildQuery
543instance ApproxEq FuzzyQuery
556instance ApproxEq FuzzyQuery
544instance ApproxEq FuzzyLikeFieldQuery
557instance ApproxEq FuzzyLikeFieldQuery
545instance ApproxEq FuzzyLikeThisQuery
558instance ApproxEq FuzzyLikeThisQuery
546−instance ApproxEq FilteredQuery
547instance ApproxEq DisMaxQuery
559instance ApproxEq DisMaxQuery
548instance ApproxEq CommonTermsQuery
560instance ApproxEq CommonTermsQuery
549instance ApproxEq CommonMinimumMatch
561instance ApproxEq CommonMinimumMatch
@@ -577,7 +589,7 @@ instance ApproxEq BoolMatch
577instance ApproxEq MultiMatchQuery
589instance ApproxEq MultiMatchQuery
578instance ApproxEq IndexSettings
590instance ApproxEq IndexSettings
579instance ApproxEq AllocationPolicy
591instance ApproxEq AllocationPolicy
580−instance ApproxEq Char
592+instance ApproxEq Char where (=~) = (==)
581instance ApproxEq Vers.Version where
593instance ApproxEq Vers.Version where
582 (=~) = (==)
594 (=~) = (==)
583instance (ApproxEq a, Show a) => ApproxEq [a] where
595instance (ApproxEq a, Show a) => ApproxEq [a] where
@@ -722,10 +734,8 @@ instance Arbitrary Query where
722 , QueryBoolQuery <$> arbitrary
734 , QueryBoolQuery <$> arbitrary
723 , QueryBoostingQuery <$> arbitrary
735 , QueryBoostingQuery <$> arbitrary
724 , QueryCommonTermsQuery <$> arbitrary
736 , QueryCommonTermsQuery <$> arbitrary
725− , ConstantScoreFilter <$> arbitrary <*> arbitrary
726 , ConstantScoreQuery <$> arbitrary <*> arbitrary
737 , ConstantScoreQuery <$> arbitrary <*> arbitrary
727 , QueryDisMaxQuery <$> arbitrary
738 , QueryDisMaxQuery <$> arbitrary
728− , QueryFilteredQuery <$> arbitrary
729 , QueryFuzzyLikeThisQuery <$> arbitrary
739 , QueryFuzzyLikeThisQuery <$> arbitrary
730 , QueryFuzzyLikeFieldQuery <$> arbitrary
740 , QueryFuzzyLikeFieldQuery <$> arbitrary
731 , QueryFuzzyQuery <$> arbitrary
741 , QueryFuzzyQuery <$> arbitrary
@@ -746,24 +756,7 @@ instance Arbitrary Query where
746 shrink = genericShrink
756 shrink = genericShrink
747
757
748instance Arbitrary Filter where
758instance Arbitrary Filter where
749− arbitrary = reduceSize $ oneof [ AndFilter <$> arbitrary <*> arbitrary
759+ arbitrary = Filter <$> arbitrary
750− , OrFilter <$> arbitrary <*> arbitrary
751− , NotFilter <$> arbitrary <*> arbitrary
752− , pure IdentityFilter
753− , BoolFilter <$> arbitrary
754− , ExistsFilter <$> arbitrary
755− , GeoBoundingBoxFilter <$> arbitrary
756− , GeoDistanceFilter <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
757− , GeoDistanceRangeFilter <$> arbitrary <*> arbitrary
758− , GeoPolygonFilter <$> arbitrary <*> arbitrary
759− , IdsFilter <$> arbitrary <*> arbitrary
760− , LimitFilter <$> arbitrary
761− , MissingFilter <$> arbitrary <*> arbitrary <*> arbitrary
762− , PrefixFilter <$> arbitrary <*> arbitrary <*> arbitrary
763− , QueryFilter <$> arbitrary <*> arbitrary
764− , RangeFilter <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
765− , RegexpFilter <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
766− , TermFilter <$> arbitrary <*> arbitrary]
767 shrink = genericShrink
760 shrink = genericShrink
768
761
769instance Arbitrary ReplicaBounds where
762instance Arbitrary ReplicaBounds where
@@ -855,7 +848,6 @@ $(derive makeArbitrary ''HasChildQuery)
855$(derive makeArbitrary ''FuzzyQuery)
848$(derive makeArbitrary ''FuzzyQuery)
856$(derive makeArbitrary ''FuzzyLikeFieldQuery)
849$(derive makeArbitrary ''FuzzyLikeFieldQuery)
857$(derive makeArbitrary ''FuzzyLikeThisQuery)
850$(derive makeArbitrary ''FuzzyLikeThisQuery)
858−$(derive makeArbitrary ''FilteredQuery)
859$(derive makeArbitrary ''DisMaxQuery)
851$(derive makeArbitrary ''DisMaxQuery)
860$(derive makeArbitrary ''CommonTermsQuery)
852$(derive makeArbitrary ''CommonTermsQuery)
861$(derive makeArbitrary ''DistanceRange)
853$(derive makeArbitrary ''DistanceRange)
@@ -1028,7 +1020,7 @@ main = hspec $ do
1028 it "returns document for term query and identity filter" $ withTestEnv $ do
1020 it "returns document for term query and identity filter" $ withTestEnv $ do
1029 _ <- insertData
1021 _ <- insertData
1030 let query = TermQuery (Term "user" "bitemyapp") Nothing
1022 let query = TermQuery (Term "user" "bitemyapp") Nothing
1031− let filter = IdentityFilter <&&> IdentityFilter
1023+ let filter = Filter $ MatchAllQuery Nothing
1032 let search = mkSearch (Just query) (Just filter)
1024 let search = mkSearch (Just query) (Just filter)
1033 myTweet <- searchTweet search
1025 myTweet <- searchTweet search
1034 liftIO $
1026 liftIO $
@@ -1038,26 +1030,16 @@ main = hspec $ do
1038 _ <- insertData
1030 _ <- insertData
1039 let query = TermsQuery "user" ("bitemyapp" :| [])
1031 let query = TermsQuery "user" ("bitemyapp" :| [])
1040 let cfQuery = ConstantScoreQuery query (Boost 1.0)
1032 let cfQuery = ConstantScoreQuery query (Boost 1.0)
1041− let filter = IdentityFilter
1033+ let filter = Filter $ MatchAllQuery Nothing
1042 let search = mkSearch (Just cfQuery) (Just filter)
1034 let search = mkSearch (Just cfQuery) (Just filter)
1043 myTweet <- searchTweet search
1035 myTweet <- searchTweet search
1044 liftIO $
1036 liftIO $
1045 myTweet `shouldBe` Right exampleTweet
1037 myTweet `shouldBe` Right exampleTweet
1046− it "handles constant score filters" $ withTestEnv $ do
1047− _ <- insertData
1048− let query = TermsQuery "user" ("bitemyapp" :| [])
1049− let cfFilter = ConstantScoreFilter IdentityFilter (Boost 1.0)
1050− let boolQuery = mkBoolQuery [query, cfFilter] [] []
1051− let search = mkSearch (Just (QueryBoolQuery boolQuery)) Nothing
1052− myTweet <- searchTweet search
1053− liftIO $
1054− myTweet `shouldBe` Right exampleTweet
1055−
1056
1038
1057 it "returns document for terms query and identity filter" $ withTestEnv $ do
1039 it "returns document for terms query and identity filter" $ withTestEnv $ do
1058 _ <- insertData
1040 _ <- insertData
1059 let query = TermsQuery "user" ("bitemyapp" :| [])
1041 let query = TermsQuery "user" ("bitemyapp" :| [])
1060− let filter = IdentityFilter <&&> IdentityFilter
1042+ let filter = Filter $ MatchAllQuery Nothing
1061 let search = mkSearch (Just query) (Just filter)
1043 let search = mkSearch (Just query) (Just filter)
1062 myTweet <- searchTweet search
1044 myTweet <- searchTweet search
1063 liftIO $
1045 liftIO $
@@ -1085,7 +1067,7 @@ main = hspec $ do
1085 let innerQuery = QueryMatchQuery $
1067 let innerQuery = QueryMatchQuery $
1086 mkMatchQuery (FieldName "user") (QueryString "bitemyapp")
1068 mkMatchQuery (FieldName "user") (QueryString "bitemyapp")
1087 let query = QueryBoolQuery $
1069 let query = QueryBoolQuery $
1088− mkBoolQuery [innerQuery] [] []
1070+ mkBoolQuery [innerQuery] [] [] []
1089 let search = mkSearch (Just query) Nothing
1071 let search = mkSearch (Just query) Nothing
1090 myTweet <- searchTweet search
1072 myTweet <- searchTweet search
1091 liftIO $
1073 liftIO $
@@ -1120,173 +1102,13 @@ main = hspec $ do
1120 _ <- insertOther
1102 _ <- insertOther
1121 let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
1103 let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
1122 let search = Search Nothing
1104 let search = Search Nothing
1123− (Just IdentityFilter) (Just [sortSpec]) Nothing Nothing
1105+ Nothing (Just [sortSpec]) Nothing Nothing
1124 False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
1106 False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
1125 result <- searchTweets search
1107 result <- searchTweets search
1126 let myTweet = grabFirst result
1108 let myTweet = grabFirst result
1127 liftIO $
1109 liftIO $
1128 myTweet `shouldBe` Right otherTweet
1110 myTweet `shouldBe` Right otherTweet
1129
1111
1130−
1131− describe "filtering API" $ do
1132− it "returns document for composed boolmatch and identity" $ withTestEnv $ do
1133− _ <- insertData
1134− let queryFilter = BoolFilter (MustMatch (Term "user" "bitemyapp") False)
1135− <&&> IdentityFilter
1136− let search = mkSearch Nothing (Just queryFilter)
1137− myTweet <- searchTweet search
1138− liftIO $
1139− myTweet `shouldBe` Right exampleTweet
1140−
1141− it "returns document for term filter" $ withTestEnv $ do
1142− _ <- insertData
1143− let termFilter = TermFilter (Term "user" "bitemyapp") False
1144− let search = mkSearch Nothing (Just termFilter)
1145− myTweet <- searchTweet search
1146− liftIO $
1147− myTweet `shouldBe` Right exampleTweet
1148−
1149− it "returns document for existential filter" $ withTestEnv $ do
1150− _ <- insertData
1151− let search = mkSearch Nothing (Just (ExistsFilter (FieldName "user")))
1152− myTweet <- searchTweet search
1153− liftIO $
1154− myTweet `shouldBe` Right exampleTweet
1155−
1156− it "returns document for geo boundingbox filter" $ withTestEnv $ do
1157− _ <- insertData
1158− let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
1159− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
1160− let geoFilter = GeoBoundingBoxFilter bbConstraint
1161− let search = mkSearch Nothing (Just geoFilter)
1162− myTweet <- searchTweet search
1163− liftIO $
1164− myTweet `shouldBe` Right exampleTweet
1165−
1166− it "doesn't return document for nonsensical boundingbox filter" $ withTestEnv $ do
1167− _ <- insertData
1168− let box = GeoBoundingBox (LatLon 0.73 (-4.1)) (LatLon 0.10 (-1.12))
1169− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
1170− let geoFilter = GeoBoundingBoxFilter bbConstraint
1171− let search = mkSearch Nothing (Just geoFilter)
1172− searchExpectNoResults search
1173−
1174− it "returns document for geo distance filter" $ withTestEnv $ do
1175− _ <- insertData
1176− let geoPoint = GeoPoint (FieldName "tweet.location") (LatLon 40.12 (-71.34))
1177− let distance = Distance 10.0 Miles
1178− let optimizeBbox = OptimizeGeoFilterType GeoFilterMemory
1179− let geoFilter = GeoDistanceFilter geoPoint distance SloppyArc optimizeBbox False
1180− let search = mkSearch Nothing (Just geoFilter)
1181− myTweet <- searchTweet search
1182− liftIO $
1183− myTweet `shouldBe` Right exampleTweet
1184−
1185− it "returns document for geo distance range filter" $ withTestEnv $ do
1186− _ <- insertData
1187− let geoPoint = GeoPoint (FieldName "tweet.location") (LatLon 40.12 (-71.34))
1188− let distanceRange = DistanceRange (Distance 0.0 Miles) (Distance 10.0 Miles)
1189− let geoFilter = GeoDistanceRangeFilter geoPoint distanceRange
1190− let search = mkSearch Nothing (Just geoFilter)
1191− myTweet <- searchTweet search
1192− liftIO $
1193− myTweet `shouldBe` Right exampleTweet
1194−
1195− it "doesn't return document for wild geo distance range filter" $ withTestEnv $ do
1196− _ <- insertData
1197− let geoPoint = GeoPoint (FieldName "tweet.location") (LatLon 40.12 (-71.34))
1198− let distanceRange = DistanceRange (Distance 100.0 Miles) (Distance 1000.0 Miles)
1199− let geoFilter = GeoDistanceRangeFilter geoPoint distanceRange
1200− let search = mkSearch Nothing (Just geoFilter)
1201− searchExpectNoResults search
1202−
1203− it "returns document for geo polygon filter" $ withTestEnv $ do
1204− _ <- insertData
1205− let points = [LatLon 40.0 (-70.00),
1206− LatLon 40.0 (-72.00),
1207− LatLon 41.0 (-70.00),
1208− LatLon 41.0 (-72.00)]
1209− let geoFilter = GeoPolygonFilter (FieldName "tweet.location") points
1210− let search = mkSearch Nothing (Just geoFilter)
1211− myTweet <- searchTweet search
1212− liftIO $
1213− myTweet `shouldBe` Right exampleTweet
1214−
1215− it "doesn't return document for bad geo polygon filter" $ withTestEnv $ do
1216− _ <- insertData
1217− let points = [LatLon 40.0 (-70.00),
1218− LatLon 40.0 (-71.00),
1219− LatLon 41.0 (-70.00),
1220− LatLon 41.0 (-71.00)]
1221− let geoFilter = GeoPolygonFilter (FieldName "tweet.location") points
1222− let search = mkSearch Nothing (Just geoFilter)
1223− searchExpectNoResults search
1224−
1225− it "returns document for ids filter" $ withTestEnv $ do
1226− _ <- insertData
1227− let filter = IdsFilter (MappingName "tweet") [DocId "1"]
1228− let search = mkSearch Nothing (Just filter)
1229− myTweet <- searchTweet search
1230− liftIO $
1231− myTweet `shouldBe` Right exampleTweet
1232−
1233− it "returns document for Double range filter" $ withTestEnv $ do
1234− _ <- insertData
1235− let filter = RangeFilter (FieldName "age")
1236− (RangeDoubleGtLt (GreaterThan 1000.0) (LessThan 100000.0))
1237− RangeExecutionIndex False
1238− let search = mkSearch Nothing (Just filter)
1239− myTweet <- searchTweet search
1240− liftIO $
1241− myTweet `shouldBe` Right exampleTweet
1242−
1243− it "returns document for UTCTime date filter" $ withTestEnv $ do
1244− _ <- insertData
1245− let filter = RangeFilter (FieldName "postDate")
1246− (RangeDateGtLt
1247− (GreaterThanD (UTCTime
1248− (ModifiedJulianDay 54000)
1249− (secondsToDiffTime 0)))
1250− (LessThanD (UTCTime
1251− (ModifiedJulianDay 55000)
1252− (secondsToDiffTime 11))))
1253− RangeExecutionIndex False
1254− let search = mkSearch Nothing (Just filter)
1255− myTweet <- searchTweet search
1256− liftIO $
1257− myTweet `shouldBe` Right exampleTweet
1258−
1259− it "returns document for regexp filter" $ withTestEnv $ do
1260− _ <- insertData
1261− let filter = RegexpFilter (FieldName "user") (Regexp "bite.*app")
1262− AllRegexpFlags (CacheName "test") False (CacheKey "key")
1263− let search = mkSearch Nothing (Just filter)
1264− myTweet <- searchTweet search
1265− liftIO $
1266− myTweet `shouldBe` Right exampleTweet
1267−
1268− it "doesn't return document for non-matching regexp filter" $ withTestEnv $ do
1269− _ <- insertData
1270− let filter = RegexpFilter (FieldName "user")
1271− (Regexp "boy") AllRegexpFlags
1272− (CacheName "test") False (CacheKey "key")
1273− let search = mkSearch Nothing (Just filter)
1274− searchExpectNoResults search
1275−
1276− it "returns document for query filter, uncached" $ withTestEnv $ do
1277− _ <- insertData
1278− let filter = QueryFilter (TermQuery (Term "user" "bitemyapp") Nothing) True
1279− search = mkSearch Nothing (Just filter)
1280− myTweet <- searchTweet search
1281− liftIO $ myTweet `shouldBe` Right exampleTweet
1282−
1283− it "returns document for query filter, cached" $ withTestEnv $ do
1284− _ <- insertData
1285− let filter = QueryFilter (TermQuery (Term "user" "bitemyapp") Nothing) False
1286− search = mkSearch Nothing (Just filter)
1287− myTweet <- searchTweet search
1288− liftIO $ myTweet `shouldBe` Right exampleTweet
1289−
1290 describe "Aggregation API" $ do
1112 describe "Aggregation API" $ do
1291 it "returns term aggregation results" $ withTestEnv $ do
1113 it "returns term aggregation results" $ withTestEnv $ do
1292 _ <- insertData
1114 _ <- insertData
@@ -1340,18 +1162,6 @@ main = hspec $ do
1340 , docCountPair "bogus_count" 0
1162 , docCountPair "bogus_count" 0
1341 ]))
1163 ]))
1342
1164
1343− it "can execute filter aggregations" $ withTestEnv $ do
1344− _ <- insertData
1345− _ <- insertOther
1346− let ags = mkAggregations "bitemyapps" (FilterAgg (FilterAggregation (TermFilter (Term "user" "bitemyapp") defaultCache) Nothing)) <>
1347− mkAggregations "notmyapps" (FilterAgg (FilterAggregation (TermFilter (Term "user" "notmyapp") defaultCache) Nothing))
1348− let search = mkAggregateSearch Nothing ags
1349− let docCountPair k n = (k, object ["doc_count" .= Number n])
1350− res <- searchTweets search
1351− liftIO $
1352− fmap aggregations res `shouldBe` Right (Just (M.fromList [ docCountPair "bitemyapps" 1
1353− , docCountPair "notmyapps" 1
1354− ]))
1355 it "can execute date_range aggregations" $ withTestEnv $ do
1165 it "can execute date_range aggregations" $ withTestEnv $ do
1356 let now = fromGregorian 2015 3 14
1166 let now = fromGregorian 2015 3 14
1357 let ltAMonthAgo = UTCTime (fromGregorian 2015 3 1) 0
1167 let ltAMonthAgo = UTCTime (fromGregorian 2015 3 1) 0
@@ -1397,18 +1207,6 @@ main = hspec $ do
1397 searchExpectAggs search
1207 searchExpectAggs search
1398 searchValidBucketAgg search "byDate" toDateHistogram
1208 searchValidBucketAgg search "byDate" toDateHistogram
1399
1209
1400− it "returns date histogram using fractional date" $ withTestEnv $ do
1401− _ <- insertData
1402− let periods = [Year, Quarter, Month, Week, Day, Hour, Minute, Second]
1403− let fractionals = map (FractionalInterval 1.5) [Weeks, Days, Hours, Minutes, Seconds]
1404− let intervals = periods ++ fractionals
1405− let histogram = mkDateHistogram (FieldName "postDate")
1406− let search interval = mkAggregateSearch Nothing $ mkAggregations "byDate" $ DateHistogramAgg (histogram interval)
1407− let expect interval = searchExpectAggs (search interval)
1408− let valid interval = searchValidBucketAgg (search interval) "byDate" toDateHistogram
1409− forM_ intervals expect
1410− forM_ intervals valid
1411−
1412 it "can execute missing aggregations" $ withTestEnv $ do
1210 it "can execute missing aggregations" $ withTestEnv $ do
1413 _ <- insertData
1211 _ <- insertData
1414 _ <- insertExtra
1212 _ <- insertExtra
@@ -1424,7 +1222,7 @@ main = hspec $ do
1424 it "returns highlight from query when there should be one" $ withTestEnv $ do
1222 it "returns highlight from query when there should be one" $ withTestEnv $ do
1425 _ <- insertData
1223 _ <- insertData
1426 _ <- insertOther
1224 _ <- insertOther
1427− let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
1225+ let query = QueryMatchQuery $ mkMatchQuery (FieldName "message") (QueryString "haskell")
1428 let testHighlight = Highlights Nothing [FieldHighlight (FieldName "message") Nothing]
1226 let testHighlight = Highlights Nothing [FieldHighlight (FieldName "message") Nothing]
1429
1227
1430 let search = mkHighlightSearch (Just query) testHighlight
1228 let search = mkHighlightSearch (Just query) testHighlight
@@ -1435,7 +1233,7 @@ main = hspec $ do
1435 it "doesn't return highlight from a query when it shouldn't" $ withTestEnv $ do
1233 it "doesn't return highlight from a query when it shouldn't" $ withTestEnv $ do
1436 _ <- insertData
1234 _ <- insertData
1437 _ <- insertOther
1235 _ <- insertOther
1438− let query = QueryMatchQuery $ mkMatchQuery (FieldName "_all") (QueryString "haskell")
1236+ let query = QueryMatchQuery $ mkMatchQuery (FieldName "message") (QueryString "haskell")
1439 let testHighlight = Highlights Nothing [FieldHighlight (FieldName "user") Nothing]
1237 let testHighlight = Highlights Nothing [FieldHighlight (FieldName "user") Nothing]
1440
1238
1441 let search = mkHighlightSearch (Just query) testHighlight
1239 let search = mkHighlightSearch (Just query) testHighlight
@@ -1691,27 +1489,6 @@ main = hspec $ do
1691 L.find ((== alias) . indexAliasSummaryAlias) summs `shouldBe` Just expected
1489 L.find ((== alias) . indexAliasSummaryAlias) summs `shouldBe` Just expected
1692 Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)) `finally` cleanup
1490 Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)) `finally` cleanup
1693
1491
1694− it "handles an alias with routing and a filter" $ do
1695− let alias = IndexAlias (testIndex) (IndexAliasName (IndexName "bloodhound-tests-twitter-1-alias"))
1696− let sar = SearchAliasRouting (RoutingValue "search val" :| [])
1697− let iar = IndexAliasRouting (RoutingValue "index val")
1698− let routing = GranularAliasRouting (Just sar) (Just iar)
1699− let filter = LimitFilter 42
1700− let create = IndexAliasCreate (Just routing) (Just filter)
1701− let action = AddAlias alias create
1702−
1703− withTestEnv $ do
1704− resetIndex
1705− resp <- updateIndexAliases (action :| [])
1706− liftIO $ validateStatus resp 200
1707− let cleanup = withTestEnv (updateIndexAliases (RemoveAlias alias :| []))
1708− (do aliases <- withTestEnv getIndexAliases
1709− let expected = IndexAliasSummary alias create
1710− case aliases of
1711− Right (IndexAliasesSummary summs) ->
1712− L.find ((== alias) . indexAliasSummaryAlias) summs `shouldBe` Just expected
1713− Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)) `finally` cleanup
1714−
1715 describe "Index Listing" $ do
1492 describe "Index Listing" $ do
1716 it "returns a list of index names" $ withTestEnv $ do
1493 it "returns a list of index names" $ withTestEnv $ do
1717 _ <- createExampleIndex
1494 _ <- createExampleIndex
@@ -1735,7 +1512,7 @@ main = hspec $ do
1735 describe "Index Optimization" $ do
1512 describe "Index Optimization" $ do
1736 it "returns a successful response upon completion" $ withTestEnv $ do
1513 it "returns a successful response upon completion" $ withTestEnv $ do
1737 _ <- createExampleIndex
1514 _ <- createExampleIndex
1738− resp <- optimizeIndex (IndexList (testIndex :| [])) defaultIndexOptimizationSettings
1515+ resp <- forceMergeIndex (IndexList (testIndex :| [])) defaultForceMergeIndexSettings
1739 liftIO $ validateStatus resp 200
1516 liftIO $ validateStatus resp 200
1740
1517
1741 describe "JSON instances" $ do
1518 describe "JSON instances" $ do
@@ -1801,7 +1578,6 @@ main = hspec $ do
1801 propJSON (Proxy :: Proxy FuzzyQuery)
1578 propJSON (Proxy :: Proxy FuzzyQuery)
1802 propJSON (Proxy :: Proxy FuzzyLikeFieldQuery)
1579 propJSON (Proxy :: Proxy FuzzyLikeFieldQuery)
1803 propJSON (Proxy :: Proxy FuzzyLikeThisQuery)
1580 propJSON (Proxy :: Proxy FuzzyLikeThisQuery)
1804− propJSON (Proxy :: Proxy FilteredQuery)
1805 propJSON (Proxy :: Proxy DisMaxQuery)
1581 propJSON (Proxy :: Proxy DisMaxQuery)
1806 propJSON (Proxy :: Proxy CommonTermsQuery)
1582 propJSON (Proxy :: Proxy CommonTermsQuery)
1807 propJSON (Proxy :: Proxy CommonMinimumMatch)
1583 propJSON (Proxy :: Proxy CommonMinimumMatch)