bloodhound 0.20.0.2 → 0.21.0.0
raw patch · 15 files changed
+468/−204 lines, 15 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Database.Bloodhound.Client: IndexedDocument :: Text -> Text -> Text -> Int -> Text -> ShardCount -> Int -> Int -> IndexedDocument
+ Database.Bloodhound.Client: IndexedDocument :: Text -> Text -> Text -> Int -> Text -> ShardResult -> Int -> Int -> IndexedDocument
- Database.Bloodhound.Client: [idxDocShards] :: IndexedDocument -> ShardCount
+ Database.Bloodhound.Client: [idxDocShards] :: IndexedDocument -> ShardResult
Files
- README.md +94/−0
- bloodhound.cabal +1/−1
- changelog.md +6/−0
- src/Database/Bloodhound/Client.hs +6/−5
- src/Database/Bloodhound/Common/Script.hs +6/−3
- src/Database/Bloodhound/Internal/Analysis.hs +3/−1
- src/Database/Bloodhound/Internal/Client.hs +248/−128
- src/Database/Bloodhound/Internal/Client/BHRequest.hs +9/−10
- src/Database/Bloodhound/Internal/Client/Doc.hs +1/−1
- src/Database/Bloodhound/Internal/Highlight.hs +4/−4
- src/Database/Bloodhound/Internal/Query.hs +80/−46
- tests/Test/BulkAPI.hs +2/−1
- tests/Test/Generators.hs +5/−2
- tests/Test/Snapshots.hs +1/−1
- tests/tests.hs +2/−1
README.md view
@@ -63,6 +63,100 @@ See the [examples](htts://github.com/bitemyapp/bloodhound/tree/master/examples) directory for example code. +Index a document+----------------++```haskell+indexDocument testIndex defaultIndexDocumentSettings exampleTweet (DocId "1")+{-+IndexedDocument+ { idxDocIndex = "twitter"+ , idxDocType = "_doc"+ , idxDocId = "1"+ , idxDocVersion = 3+ , idxDocResult = "updated"+ , idxDocShards =+ ShardResult+ { shardTotal = 1+ , shardsSuccessful = 1+ , shardsSkipped = 0+ , shardsFailed = 0+ }+ , idxDocSeqNo = 2+ , idxDocPrimaryTerm = 1+ }+-}+```++Fetch documents+---------------++```haskell+let query = TermQuery (Term "user" "bitemyapp") boost+let search = mkSearch (Just query) boost+searchByIndex @_ @Tweet testIndex search+{-+SearchResult+ { took = 1+ , timedOut = False+ , shards =+ ShardResult+ { shardTotal = 1+ , shardsSuccessful = 1+ , shardsSkipped = 0+ , shardsFailed = 0+ }+ , searchHits =+ SearchHits+ { hitsTotal = HitsTotal { value = 2 , relation = HTR_EQ }+ , maxScore = Just 0.18232156+ , hits =+ [ Hit+ { hitIndex = IndexName "twitter"+ , hitDocId = DocId "1"+ , hitScore = Just 0.18232156+ , hitSource =+ Just+ Tweet+ { user = "bitemyapp"+ , postDate = 2009-06-18 00:00:10 UTC+ , message = "Use haskell!"+ , age = 10000+ , location = LatLon { lat = 40.12 , lon = -71.3 }+ }+ , hitSort = Nothing+ , hitFields = Nothing+ , hitHighlight = Nothing+ , hitInnerHits = Nothing+ }+ , Hit+ { hitIndex = IndexName "twitter"+ , hitDocId = DocId "2"+ , hitScore = Just 0.18232156+ , hitSource =+ Just+ Tweet+ { user = "bitemyapp"+ , postDate = 2009-06-18 00:00:10 UTC+ , message = "Use haskell!"+ , age = 10000+ , location = LatLon { lat = 40.12 , lon = -71.3 }+ }+ , hitSort = Nothing+ , hitFields = Nothing+ , hitHighlight = Nothing+ , hitInnerHits = Nothing+ }+ ]+ }+ , aggregations = Nothing+ , scrollId = Nothing+ , suggest = Nothing+ , pitId = Nothing+ }+-}+```+ Contributors ============
bloodhound.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: bloodhound-version: 0.20.0.2+version: 0.21.0.0 synopsis: Elasticsearch client library for Haskell description: Elasticsearch made awesome for Haskell hackers category: Database, Search
changelog.md view
@@ -1,3 +1,9 @@+0.21.0.0+========+- @blackheaven+ - Fix `indexDocument` `Response` type+ - Fix `Acknowledged` and `Accepted` `FromJSON`+ 0.20.0.0 ======== - @blackheaven
src/Database/Bloodhound/Client.hs view
@@ -328,7 +328,8 @@ where parse = fmap GSRs . mapM (uncurry go) . X.toList go rawName = withObject "GenericSnapshotRepo" $ \o ->- GenericSnapshotRepo (SnapshotRepoName $ toText rawName) <$> o .: "type"+ GenericSnapshotRepo (SnapshotRepoName $ toText rawName)+ <$> o .: "type" <*> o .: "settings" -- | Create or update a snapshot repo@@ -525,8 +526,8 @@ object [ "settings" .= deepMerge- ( X.singleton "index.number_of_shards" (toJSON shards) :- [u | Object u <- toJSON <$> updates]+ ( X.singleton "index.number_of_shards" (toJSON shards)+ : [u | Object u <- toJSON <$> updates] ) ] @@ -839,7 +840,7 @@ -- -- >>> resp <- runBH' $ indexDocument testIndex defaultIndexDocumentSettings exampleTweet (DocId "1") -- >>> print resp--- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("content-length","152")], responseBody = "{\"_index\":\"bloodhound-tests-twitter-1\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\",\"_shards\":{\"total\":1,\"successful\":1,\"failed\":0},\"_seq_no\":1,\"_primary_term\":1}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}+-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("content-length","152")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\",\"_shards\":{\"total\":1,\"successful\":1,\"failed\":0},\"_seq_no\":1,\"_primary_term\":1}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose} indexDocument :: (ToJSON doc, MonadBH m) => IndexName ->@@ -859,7 +860,7 @@ idxDocId :: Text, idxDocVersion :: Int, idxDocResult :: Text,- idxDocShards :: ShardCount,+ idxDocShards :: ShardResult, idxDocSeqNo :: Int, idxDocPrimaryTerm :: Int }
src/Database/Bloodhound/Common/Script.hs view
@@ -146,9 +146,12 @@ parseFunctionScoreFunction :: Object -> Parser FunctionScoreFunction parseFunctionScoreFunction o =- singleScript `taggedWith` "script_score"- <|> singleRandom `taggedWith` "random_score"- <|> singleFieldValueFactor `taggedWith` "field_value_factor"+ singleScript+ `taggedWith` "script_score"+ <|> singleRandom+ `taggedWith` "random_score"+ <|> singleFieldValueFactor+ `taggedWith` "field_value_factor" where taggedWith parser k = parser =<< o .: k singleScript = pure . FunctionScoreFunctionScript
src/Database/Bloodhound/Internal/Analysis.hs view
@@ -100,7 +100,9 @@ _ -> fail "mapping is not of the format key => value" "pattern_replace" -> CharFilterDefinitionPatternReplace- <$> m .: "pattern" <*> m .: "replacement" <*> m .:? "flags"+ <$> m .: "pattern"+ <*> m .: "replacement"+ <*> m .:? "flags" _ -> fail ("unrecognized character filter type: " ++ T.unpack t) data TokenizerDefinition
src/Database/Bloodhound/Internal/Client.hs view
@@ -157,7 +157,8 @@ parse o = do s <- o .: "settings" i <- s .: "index"- IndexSettings <$> i .: "number_of_shards"+ IndexSettings+ <$> i .: "number_of_shards" <*> i .: "number_of_replicas" <*> i .:? "mapping" .!= defaultIndexMappingsLimits @@ -342,38 +343,70 @@ parseJSON = withObject "UpdatableIndexSetting" parse where parse o =- numberOfReplicas `taggedAt` ["index", "number_of_replicas"]- <|> autoExpandReplicas `taggedAt` ["index", "auto_expand_replicas"]- <|> refreshInterval `taggedAt` ["index", "refresh_interval"]- <|> indexConcurrency `taggedAt` ["index", "concurrency"]- <|> failOnMergeFailure `taggedAt` ["index", "fail_on_merge_failure"]- <|> translogFlushThresholdOps `taggedAt` ["index", "translog", "flush_threshold_ops"]- <|> translogFlushThresholdSize `taggedAt` ["index", "translog", "flush_threshold_size"]- <|> translogFlushThresholdPeriod `taggedAt` ["index", "translog", "flush_threshold_period"]- <|> translogDisableFlush `taggedAt` ["index", "translog", "disable_flush"]- <|> cacheFilterMaxSize `taggedAt` ["index", "cache", "filter", "max_size"]- <|> cacheFilterExpire `taggedAt` ["index", "cache", "filter", "expire"]- <|> gatewaySnapshotInterval `taggedAt` ["index", "gateway", "snapshot_interval"]- <|> routingAllocationInclude `taggedAt` ["index", "routing", "allocation", "include"]- <|> routingAllocationExclude `taggedAt` ["index", "routing", "allocation", "exclude"]- <|> routingAllocationRequire `taggedAt` ["index", "routing", "allocation", "require"]- <|> routingAllocationEnable `taggedAt` ["index", "routing", "allocation", "enable"]- <|> routingAllocationShardsPerNode `taggedAt` ["index", "routing", "allocation", "total_shards_per_node"]- <|> recoveryInitialShards `taggedAt` ["index", "recovery", "initial_shards"]- <|> gcDeletes `taggedAt` ["index", "gc_deletes"]- <|> ttlDisablePurge `taggedAt` ["index", "ttl", "disable_purge"]- <|> translogFSType `taggedAt` ["index", "translog", "fs", "type"]- <|> compressionSetting `taggedAt` ["index", "codec"]- <|> compoundFormat `taggedAt` ["index", "compound_format"]- <|> compoundOnFlush `taggedAt` ["index", "compound_on_flush"]- <|> warmerEnabled `taggedAt` ["index", "warmer", "enabled"]- <|> blocksReadOnly `taggedAt` ["blocks", "read_only"]- <|> blocksRead `taggedAt` ["blocks", "read"]- <|> blocksWrite `taggedAt` ["blocks", "write"]- <|> blocksMetaData `taggedAt` ["blocks", "metadata"]- <|> mappingTotalFieldsLimit `taggedAt` ["index", "mapping", "total_fields", "limit"]- <|> analysisSetting `taggedAt` ["index", "analysis"]- <|> unassignedNodeLeftDelayedTimeout `taggedAt` ["index", "unassigned", "node_left", "delayed_timeout"]+ numberOfReplicas+ `taggedAt` ["index", "number_of_replicas"]+ <|> autoExpandReplicas+ `taggedAt` ["index", "auto_expand_replicas"]+ <|> refreshInterval+ `taggedAt` ["index", "refresh_interval"]+ <|> indexConcurrency+ `taggedAt` ["index", "concurrency"]+ <|> failOnMergeFailure+ `taggedAt` ["index", "fail_on_merge_failure"]+ <|> translogFlushThresholdOps+ `taggedAt` ["index", "translog", "flush_threshold_ops"]+ <|> translogFlushThresholdSize+ `taggedAt` ["index", "translog", "flush_threshold_size"]+ <|> translogFlushThresholdPeriod+ `taggedAt` ["index", "translog", "flush_threshold_period"]+ <|> translogDisableFlush+ `taggedAt` ["index", "translog", "disable_flush"]+ <|> cacheFilterMaxSize+ `taggedAt` ["index", "cache", "filter", "max_size"]+ <|> cacheFilterExpire+ `taggedAt` ["index", "cache", "filter", "expire"]+ <|> gatewaySnapshotInterval+ `taggedAt` ["index", "gateway", "snapshot_interval"]+ <|> routingAllocationInclude+ `taggedAt` ["index", "routing", "allocation", "include"]+ <|> routingAllocationExclude+ `taggedAt` ["index", "routing", "allocation", "exclude"]+ <|> routingAllocationRequire+ `taggedAt` ["index", "routing", "allocation", "require"]+ <|> routingAllocationEnable+ `taggedAt` ["index", "routing", "allocation", "enable"]+ <|> routingAllocationShardsPerNode+ `taggedAt` ["index", "routing", "allocation", "total_shards_per_node"]+ <|> recoveryInitialShards+ `taggedAt` ["index", "recovery", "initial_shards"]+ <|> gcDeletes+ `taggedAt` ["index", "gc_deletes"]+ <|> ttlDisablePurge+ `taggedAt` ["index", "ttl", "disable_purge"]+ <|> translogFSType+ `taggedAt` ["index", "translog", "fs", "type"]+ <|> compressionSetting+ `taggedAt` ["index", "codec"]+ <|> compoundFormat+ `taggedAt` ["index", "compound_format"]+ <|> compoundOnFlush+ `taggedAt` ["index", "compound_on_flush"]+ <|> warmerEnabled+ `taggedAt` ["index", "warmer", "enabled"]+ <|> blocksReadOnly+ `taggedAt` ["blocks", "read_only"]+ <|> blocksRead+ `taggedAt` ["blocks", "read"]+ <|> blocksWrite+ `taggedAt` ["blocks", "write"]+ <|> blocksMetaData+ `taggedAt` ["blocks", "metadata"]+ <|> mappingTotalFieldsLimit+ `taggedAt` ["index", "mapping", "total_fields", "limit"]+ <|> analysisSetting+ `taggedAt` ["index", "analysis"]+ <|> unassignedNodeLeftDelayedTimeout+ `taggedAt` ["index", "unassigned", "node_left", "delayed_timeout"] where taggedAt f ks = taggedAt' f (Object o) ks taggedAt' f v [] =@@ -438,7 +471,8 @@ parseText t = case T.splitOn "-" t of [a, "all"] -> ReplicasLowerBounded <$> parseReadText a [a, b] ->- ReplicasBounded <$> parseReadText a+ ReplicasBounded+ <$> parseReadText a <*> parseReadText b _ -> fail ("Could not parse ReplicaBounds: " <> show t) parseBool False = pure ReplicasUnbounded@@ -830,7 +864,8 @@ parseJSON v = withObject "IndexAliasCreate" parse v where parse o =- IndexAliasCreate <$> optional (parseJSON v)+ IndexAliasCreate+ <$> optional (parseJSON v) <*> o .:? "filter" -- | 'IndexAliasSummary' is a summary of an index alias configured for a server.@@ -861,7 +896,7 @@ -- | 'IndexSelection' is used for APIs which take a single index, a list of -- indexes, or the special @_all@ index. ---TODO: this does not fully support <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/multi-index.html multi-index syntax>. It wouldn't be too hard to implement but you'd have to add the optional parameters (ignore_unavailable, allow_no_indices, expand_wildcards) to any APIs using it. Also would be a breaking API.+-- TODO: this does not fully support <https://www.elastic.co/guide/en/elasticsearch/reference/1.7/multi-index.html multi-index syntax>. It wouldn't be too hard to implement but you'd have to add the optional parameters (ignore_unavailable, allow_no_indices, expand_wildcards) to any APIs using it. Also would be a breaking API. data IndexSelection = IndexList (NonEmpty IndexName) | AllIndexes@@ -1577,13 +1612,14 @@ ] fromGSnapshotRepo GenericSnapshotRepo {..} | gSnapshotRepoType == fsRepoType = do- let o = gSnapshotRepoSettingsObject gSnapshotRepoSettings- parseRepo $- FsSnapshotRepo gSnapshotRepoName <$> o .: "location"- <*> o .:? "compress" .!= False- <*> o .:? "chunk_size"- <*> o .:? "max_restore_bytes_per_sec"- <*> o .:? "max_snapshot_bytes_per_sec"+ let o = gSnapshotRepoSettingsObject gSnapshotRepoSettings+ parseRepo $+ FsSnapshotRepo gSnapshotRepoName+ <$> o .: "location"+ <*> o .:? "compress" .!= False+ <*> o .:? "chunk_size"+ <*> o .:? "max_restore_bytes_per_sec"+ <*> o .:? "max_snapshot_bytes_per_sec" | otherwise = Left (RepoTypeMismatch fsRepoType gSnapshotRepoType) parseRepo :: Parser a -> Either SnapshotRepoConversionError a@@ -1675,7 +1711,8 @@ parseJSON = withObject "SnapshotInfo" parse where parse o =- SnapshotInfo <$> o .: "shards"+ SnapshotInfo+ <$> o .: "shards" <*> o .: "failures" <*> (unMS <$> o .: "duration_in_millis") <*> (posixMS <$> o .: "end_time_in_millis")@@ -1696,7 +1733,8 @@ parseJSON = withObject "SnapshotShardFailure" parse where parse o =- SnapshotShardFailure <$> o .: "index"+ SnapshotShardFailure+ <$> o .: "index" <*> o .:? "node_id" <*> o .: "reason" <*> o .: "shard_id"@@ -1732,7 +1770,7 @@ mkRRGroupRefNum i | i >= rrGroupRefNum minBound && i <= rrGroupRefNum maxBound =- Just $ RRGroupRefNum i+ Just $ RRGroupRefNum i | otherwise = Nothing -- | Reasonable defaults for snapshot restores@@ -1801,7 +1839,8 @@ parseJSON = withObject "NodeBreakerStats" parse where parse o =- NodeBreakerStats <$> o .: "tripped"+ NodeBreakerStats+ <$> o .: "tripped" <*> o .: "overhead" <*> o .: "estimated_size_in_bytes" <*> o .: "limit_size_in_bytes"@@ -1810,14 +1849,16 @@ parseJSON = withObject "NodeHTTPStats" parse where parse o =- NodeHTTPStats <$> o .: "total_opened"+ NodeHTTPStats+ <$> o .: "total_opened" <*> o .: "current_open" instance FromJSON NodeTransportStats where parseJSON = withObject "NodeTransportStats" parse where parse o =- NodeTransportStats <$> o .: "tx_size_in_bytes"+ NodeTransportStats+ <$> o .: "tx_size_in_bytes" <*> o .: "tx_count" <*> o .: "rx_size_in_bytes" <*> o .: "rx_count"@@ -1827,7 +1868,8 @@ parseJSON = withObject "NodeFSStats" parse where parse o =- NodeFSStats <$> o .: "data"+ NodeFSStats+ <$> o .: "data" <*> o .: "total" <*> (posixMS <$> o .: "timestamp") @@ -1835,7 +1877,8 @@ parseJSON = withObject "NodeDataPathStats" parse where parse o =- NodeDataPathStats <$> (fmap unStringlyTypedDouble <$> o .:? "disk_service_time")+ NodeDataPathStats+ <$> (fmap unStringlyTypedDouble <$> o .:? "disk_service_time") <*> (fmap unStringlyTypedDouble <$> o .:? "disk_queue") <*> o .:? "disk_io_size_in_bytes" <*> o .:? "disk_write_size_in_bytes"@@ -1855,7 +1898,8 @@ parseJSON = withObject "NodeFSTotalStats" parse where parse o =- NodeFSTotalStats <$> (fmap unStringlyTypedDouble <$> o .:? "disk_service_time")+ NodeFSTotalStats+ <$> (fmap unStringlyTypedDouble <$> o .:? "disk_service_time") <*> (fmap unStringlyTypedDouble <$> o .:? "disk_queue") <*> o .:? "disk_io_size_in_bytes" <*> o .:? "disk_write_size_in_bytes"@@ -1872,7 +1916,8 @@ where parse o = do tcp <- o .: "tcp"- NodeNetworkStats <$> tcp .: "out_rsts"+ NodeNetworkStats+ <$> tcp .: "out_rsts" <*> tcp .: "in_errs" <*> tcp .: "attempt_fails" <*> tcp .: "estab_resets"@@ -1887,7 +1932,8 @@ parseJSON = withObject "NodeThreadPoolStats" parse where parse o =- NodeThreadPoolStats <$> o .: "completed"+ NodeThreadPoolStats+ <$> o .: "completed" <*> o .: "largest" <*> o .: "rejected" <*> o .: "active"@@ -1911,7 +1957,8 @@ oldM <- pools .: "old" survivorM <- pools .: "survivor" youngM <- pools .: "young"- NodeJVMStats <$> pure mapped+ NodeJVMStats+ <$> pure mapped <*> pure direct <*> pure oldC <*> pure youngC@@ -1933,7 +1980,8 @@ parseJSON = withObject "JVMBufferPoolStats" parse where parse o =- JVMBufferPoolStats <$> o .: "total_capacity_in_bytes"+ JVMBufferPoolStats+ <$> o .: "total_capacity_in_bytes" <*> o .: "used_in_bytes" <*> o .: "count" @@ -1941,14 +1989,16 @@ parseJSON = withObject "JVMGCStats" parse where parse o =- JVMGCStats <$> (unMS <$> o .: "collection_time_in_millis")+ JVMGCStats+ <$> (unMS <$> o .: "collection_time_in_millis") <*> o .: "collection_count" instance FromJSON JVMPoolStats where parseJSON = withObject "JVMPoolStats" parse where parse o =- JVMPoolStats <$> o .: "peak_max_in_bytes"+ JVMPoolStats+ <$> o .: "peak_max_in_bytes" <*> o .: "peak_used_in_bytes" <*> o .: "max_in_bytes" <*> o .: "used_in_bytes"@@ -1959,7 +2009,8 @@ parse o = do mem <- o .: "mem" cpu <- o .: "cpu"- NodeProcessStats <$> (posixMS <$> o .: "timestamp")+ NodeProcessStats+ <$> (posixMS <$> o .: "timestamp") <*> o .: "open_file_descriptors" <*> o .: "max_file_descriptors" <*> cpu .: "percent"@@ -1974,7 +2025,8 @@ mem <- o .: "mem" cpu <- o .: "cpu" load <- o .:? "load_average"- NodeOSStats <$> (posixMS <$> o .: "timestamp")+ NodeOSStats+ <$> (posixMS <$> o .: "timestamp") <*> cpu .: "percent" <*> pure load <*> mem .: "total_in_bytes"@@ -1991,7 +2043,8 @@ where parse v = case V.toList v of [one, five, fifteen] ->- LoadAvgs <$> parseJSON one+ LoadAvgs+ <$> parseJSON one <*> parseJSON five <*> parseJSON fifteen _ -> fail "Expecting a triple of Doubles"@@ -2020,85 +2073,139 @@ indexing <- o .: "indexing" store <- o .: "store" docs <- o .: "docs"- NodeIndicesStats <$> (fmap unMS <$> mRecovery .:: "throttle_time_in_millis")- <*> mRecovery .:: "current_as_target"- <*> mRecovery .:: "current_as_source"- <*> mQueryCache .:: "miss_count"- <*> mQueryCache .:: "hit_count"- <*> mQueryCache .:: "evictions"- <*> mQueryCache .:: "memory_size_in_bytes"- <*> mSuggest .:: "current"+ NodeIndicesStats+ <$> (fmap unMS <$> mRecovery .:: "throttle_time_in_millis")+ <*> mRecovery+ .:: "current_as_target"+ <*> mRecovery+ .:: "current_as_source"+ <*> mQueryCache+ .:: "miss_count"+ <*> mQueryCache+ .:: "hit_count"+ <*> mQueryCache+ .:: "evictions"+ <*> mQueryCache+ .:: "memory_size_in_bytes"+ <*> mSuggest+ .:: "current" <*> (fmap unMS <$> mSuggest .:: "time_in_millis")- <*> mSuggest .:: "total"- <*> translog .: "size_in_bytes"- <*> translog .: "operations"- <*> segments .:? "fixed_bit_set_memory_in_bytes"- <*> segments .: "version_map_memory_in_bytes"- <*> segments .:? "index_writer_max_memory_in_bytes"- <*> segments .: "index_writer_memory_in_bytes"- <*> segments .: "memory_in_bytes"- <*> segments .: "count"- <*> completion .: "size_in_bytes"- <*> mPercolate .:: "queries"- <*> mPercolate .:: "memory_size_in_bytes"- <*> mPercolate .:: "current"+ <*> mSuggest+ .:: "total"+ <*> translog+ .: "size_in_bytes"+ <*> translog+ .: "operations"+ <*> segments+ .:? "fixed_bit_set_memory_in_bytes"+ <*> segments+ .: "version_map_memory_in_bytes"+ <*> segments+ .:? "index_writer_max_memory_in_bytes"+ <*> segments+ .: "index_writer_memory_in_bytes"+ <*> segments+ .: "memory_in_bytes"+ <*> segments+ .: "count"+ <*> completion+ .: "size_in_bytes"+ <*> mPercolate+ .:: "queries"+ <*> mPercolate+ .:: "memory_size_in_bytes"+ <*> mPercolate+ .:: "current" <*> (fmap unMS <$> mPercolate .:: "time_in_millis")- <*> mPercolate .:: "total"- <*> fielddata .: "evictions"- <*> fielddata .: "memory_size_in_bytes"+ <*> mPercolate+ .:: "total"+ <*> fielddata+ .: "evictions"+ <*> fielddata+ .: "memory_size_in_bytes" <*> (unMS <$> warmer .: "total_time_in_millis")- <*> warmer .: "total"- <*> warmer .: "current"+ <*> warmer+ .: "total"+ <*> warmer+ .: "current" <*> (unMS <$> flush .: "total_time_in_millis")- <*> flush .: "total"+ <*> flush+ .: "total" <*> (unMS <$> refresh .: "total_time_in_millis")- <*> refresh .: "total"- <*> merges .: "total_size_in_bytes"- <*> merges .: "total_docs"+ <*> refresh+ .: "total"+ <*> merges+ .: "total_size_in_bytes"+ <*> merges+ .: "total_docs" <*> (unMS <$> merges .: "total_time_in_millis")- <*> merges .: "total"- <*> merges .: "current_size_in_bytes"- <*> merges .: "current_docs"- <*> merges .: "current"- <*> search .: "fetch_current"+ <*> merges+ .: "total"+ <*> merges+ .: "current_size_in_bytes"+ <*> merges+ .: "current_docs"+ <*> merges+ .: "current"+ <*> search+ .: "fetch_current" <*> (unMS <$> search .: "fetch_time_in_millis")- <*> search .: "fetch_total"- <*> search .: "query_current"+ <*> search+ .: "fetch_total"+ <*> search+ .: "query_current" <*> (unMS <$> search .: "query_time_in_millis")- <*> search .: "query_total"- <*> search .: "open_contexts"- <*> getStats .: "current"+ <*> search+ .: "query_total"+ <*> search+ .: "open_contexts"+ <*> getStats+ .: "current" <*> (unMS <$> getStats .: "missing_time_in_millis")- <*> getStats .: "missing_total"+ <*> getStats+ .: "missing_total" <*> (unMS <$> getStats .: "exists_time_in_millis")- <*> getStats .: "exists_total"+ <*> getStats+ .: "exists_total" <*> (unMS <$> getStats .: "time_in_millis")- <*> getStats .: "total"+ <*> getStats+ .: "total" <*> (fmap unMS <$> indexing .:? "throttle_time_in_millis")- <*> indexing .:? "is_throttled"- <*> indexing .:? "noop_update_total"- <*> indexing .: "delete_current"+ <*> indexing+ .:? "is_throttled"+ <*> indexing+ .:? "noop_update_total"+ <*> indexing+ .: "delete_current" <*> (unMS <$> indexing .: "delete_time_in_millis")- <*> indexing .: "delete_total"- <*> indexing .: "index_current"+ <*> indexing+ .: "delete_total"+ <*> indexing+ .: "index_current" <*> (unMS <$> indexing .: "index_time_in_millis")- <*> indexing .: "index_total"+ <*> indexing+ .: "index_total" <*> (fmap unMS <$> store .:? "throttle_time_in_millis")- <*> store .: "size_in_bytes"- <*> docs .: "deleted"- <*> docs .: "count"+ <*> store+ .: "size_in_bytes"+ <*> docs+ .: "deleted"+ <*> docs+ .: "count" instance FromJSON NodeBreakersStats where parseJSON = withObject "NodeBreakersStats" parse where parse o =- NodeBreakersStats <$> o .: "parent"+ NodeBreakersStats+ <$> o .: "parent" <*> o .: "request" <*> o .: "fielddata" parseNodeStats :: FullNodeId -> Object -> Parser NodeStats parseNodeStats fnid o =- NodeStats <$> o .: "name"+ NodeStats+ <$> o .: "name" <*> pure fnid <*> o .:? "breakers" <*> o .: "http"@@ -2113,7 +2220,8 @@ parseNodeInfo :: FullNodeId -> Object -> Parser NodeInfo parseNodeInfo nid o =- NodeInfo <$> o .:? "http_address"+ NodeInfo+ <$> o .:? "http_address" <*> o .: "build_hash" <*> o .: "version" <*> o .: "ip"@@ -2135,7 +2243,8 @@ parseJSON = withObject "NodePluginInfo" parse where parse o =- NodePluginInfo <$> o .:? "site"+ NodePluginInfo+ <$> o .:? "site" <*> o .:? "jvm" <*> o .: "description" <*> o .: "version"@@ -2145,7 +2254,8 @@ parseJSON = withObject "NodeHTTPInfo" parse where parse o =- NodeHTTPInfo <$> o .: "max_content_length_in_bytes"+ NodeHTTPInfo+ <$> o .: "max_content_length_in_bytes" <*> o .: "publish_address" <*> o .: "bound_address" @@ -2153,14 +2263,16 @@ parseJSON = withObject "BoundTransportAddress" parse where parse o =- BoundTransportAddress <$> o .: "publish_address"+ BoundTransportAddress+ <$> o .: "publish_address" <*> o .: "bound_address" instance FromJSON NodeOSInfo where parseJSON = withObject "NodeOSInfo" parse where parse o =- NodeOSInfo <$> (unMS <$> o .: "refresh_interval_in_millis")+ NodeOSInfo+ <$> (unMS <$> o .: "refresh_interval_in_millis") <*> o .: "name" <*> o .: "arch" <*> o .: "version"@@ -2171,7 +2283,8 @@ parseJSON = withObject "CPUInfo" parse where parse o =- CPUInfo <$> o .: "cache_size_in_bytes"+ CPUInfo+ <$> o .: "cache_size_in_bytes" <*> o .: "cores_per_socket" <*> o .: "total_sockets" <*> o .: "total_cores"@@ -2183,7 +2296,8 @@ parseJSON = withObject "NodeProcessInfo" parse where parse o =- NodeProcessInfo <$> o .: "mlockall"+ NodeProcessInfo+ <$> o .: "mlockall" <*> o .:? "max_file_descriptors" <*> o .: "id" <*> (unMS <$> o .: "refresh_interval_in_millis")@@ -2192,7 +2306,8 @@ parseJSON = withObject "NodeJVMInfo" parse where parse o =- NodeJVMInfo <$> o .: "memory_pools"+ NodeJVMInfo+ <$> o .: "memory_pools" <*> o .: "gc_collectors" <*> o .: "mem" <*> (posixMS <$> o .: "start_time_in_millis")@@ -2206,7 +2321,8 @@ parseJSON = withObject "JVMMemoryInfo" parse where parse o =- JVMMemoryInfo <$> o .: "direct_max_in_bytes"+ JVMMemoryInfo+ <$> o .: "direct_max_in_bytes" <*> o .: "non_heap_max_in_bytes" <*> o .: "non_heap_init_in_bytes" <*> o .: "heap_max_in_bytes"@@ -2217,7 +2333,8 @@ where parse o = do ka <- maybe (return Nothing) (fmap Just . parseStringInterval) =<< o .:? "keep_alive"- NodeThreadPoolInfo <$> (parseJSON . unStringlyTypeJSON =<< o .: "queue_size")+ NodeThreadPoolInfo+ <$> (parseJSON . unStringlyTypeJSON =<< o .: "queue_size") <*> pure ka <*> o .:? "min" <*> o .:? "max"@@ -2310,7 +2427,8 @@ parseJSON = withObject "NodeTransportInfo" parse where parse o =- NodeTransportInfo <$> (maybe (return mempty) parseProfiles =<< o .:? "profiles")+ NodeTransportInfo+ <$> (maybe (return mempty) parseProfiles =<< o .:? "profiles") <*> o .: "publish_address" <*> o .: "bound_address" parseProfiles (Object o) | X.null o = return []@@ -2322,14 +2440,16 @@ parseJSON = withObject "NodeNetworkInfo" parse where parse o =- NodeNetworkInfo <$> o .: "primary_interface"+ NodeNetworkInfo+ <$> o .: "primary_interface" <*> (unMS <$> o .: "refresh_interval_in_millis") instance FromJSON NodeNetworkInterface where parseJSON = withObject "NodeNetworkInterface" parse where parse o =- NodeNetworkInterface <$> o .: "mac_address"+ NodeNetworkInterface+ <$> o .: "mac_address" <*> o .: "name" <*> o .: "address"
src/Database/Bloodhound/Internal/Client/BHRequest.hs view
@@ -151,9 +151,9 @@ m (ParsedEsResponse body) parseEsResponse response | isSuccess response = case eitherDecode body of- Right a -> return (Right a)- Left err ->- tryParseError err+ Right a -> return (Right a)+ Left err ->+ tryParseError err | otherwise = tryParseError "Non-200 status code" where body = responseBody $ getResponse response@@ -243,7 +243,8 @@ if found then parseJSON jsonVal else return Nothing- EsResult <$> v .: "_index"+ EsResult+ <$> v .: "_index" <*> v .: "_type" <*> v .: "_id" <*> pure fr@@ -292,15 +293,13 @@ instance FromJSON Acknowledged where parseJSON =- withObject- "Acknowledged"- (.: "acknowledged")+ withObject "Acknowledged" $+ fmap Acknowledged . (.: "acknowledged") newtype Accepted = Accepted {isAccepted :: Bool} deriving stock (Eq, Show) instance FromJSON Accepted where parseJSON =- withObject- "Accepted"- (.: "accepted")+ withObject "Accepted" $+ fmap Accepted . (.: "accepted")
src/Database/Bloodhound/Internal/Client/Doc.hs view
@@ -26,7 +26,7 @@ mkDocVersion i | i >= docVersionNumber minBound && i <= docVersionNumber maxBound =- Just $ DocVersion i+ Just $ DocVersion i | otherwise = Nothing instance Bounded DocVersion where
src/Database/Bloodhound/Internal/Highlight.hs view
@@ -19,8 +19,8 @@ instance ToJSON Highlights where toJSON (Highlights global fields) = omitNulls- ( ("fields" .= fields) :- highlightSettingsPairs global+ ( ("fields" .= fields)+ : highlightSettingsPairs global ) data FieldHighlight@@ -115,8 +115,8 @@ postHighPairs :: Maybe PostingsHighlight -> [Pair] postHighPairs Nothing = [] postHighPairs (Just (PostingsHighlight pCom)) =- ("type" .= String "postings") :- commonHighlightPairs pCom+ ("type" .= String "postings")+ : commonHighlightPairs pCom fastVectorHighPairs :: Maybe FastVectorHighlight -> [Pair] fastVectorHighPairs Nothing = []
src/Database/Bloodhound/Internal/Query.hs view
@@ -134,33 +134,59 @@ parseJSON v = withObject "Query" parse v where parse o =- termQuery `taggedWith` "term"- <|> termsQuery `taggedWith` "terms"- <|> idsQuery `taggedWith` "ids"- <|> queryQueryStringQuery `taggedWith` "query_string"- <|> queryMatchQuery `taggedWith` "match"+ termQuery+ `taggedWith` "term"+ <|> termsQuery+ `taggedWith` "terms"+ <|> idsQuery+ `taggedWith` "ids"+ <|> queryQueryStringQuery+ `taggedWith` "query_string"+ <|> queryMatchQuery+ `taggedWith` "match" <|> queryMultiMatchQuery- <|> queryBoolQuery `taggedWith` "bool"- <|> queryBoostingQuery `taggedWith` "boosting"- <|> queryCommonTermsQuery `taggedWith` "common"- <|> constantScoreQuery `taggedWith` "constant_score"- <|> queryFunctionScoreQuery `taggedWith` "function_score"- <|> queryDisMaxQuery `taggedWith` "dis_max"- <|> queryFuzzyLikeThisQuery `taggedWith` "fuzzy_like_this"- <|> queryFuzzyLikeFieldQuery `taggedWith` "fuzzy_like_this_field"- <|> queryFuzzyQuery `taggedWith` "fuzzy"- <|> queryHasChildQuery `taggedWith` "has_child"- <|> queryHasParentQuery `taggedWith` "has_parent"- <|> queryIndicesQuery `taggedWith` "indices"- <|> matchAllQuery `taggedWith` "match_all"- <|> queryMoreLikeThisQuery `taggedWith` "more_like_this"- <|> queryMoreLikeThisFieldQuery `taggedWith` "more_like_this_field"- <|> queryNestedQuery `taggedWith` "nested"- <|> queryPrefixQuery `taggedWith` "prefix"- <|> queryRangeQuery `taggedWith` "range"- <|> queryRegexpQuery `taggedWith` "regexp"- <|> querySimpleQueryStringQuery `taggedWith` "simple_query_string"- <|> queryWildcardQuery `taggedWith` "wildcard"+ <|> queryBoolQuery+ `taggedWith` "bool"+ <|> queryBoostingQuery+ `taggedWith` "boosting"+ <|> queryCommonTermsQuery+ `taggedWith` "common"+ <|> constantScoreQuery+ `taggedWith` "constant_score"+ <|> queryFunctionScoreQuery+ `taggedWith` "function_score"+ <|> queryDisMaxQuery+ `taggedWith` "dis_max"+ <|> queryFuzzyLikeThisQuery+ `taggedWith` "fuzzy_like_this"+ <|> queryFuzzyLikeFieldQuery+ `taggedWith` "fuzzy_like_this_field"+ <|> queryFuzzyQuery+ `taggedWith` "fuzzy"+ <|> queryHasChildQuery+ `taggedWith` "has_child"+ <|> queryHasParentQuery+ `taggedWith` "has_parent"+ <|> queryIndicesQuery+ `taggedWith` "indices"+ <|> matchAllQuery+ `taggedWith` "match_all"+ <|> queryMoreLikeThisQuery+ `taggedWith` "more_like_this"+ <|> queryMoreLikeThisFieldQuery+ `taggedWith` "more_like_this_field"+ <|> queryNestedQuery+ `taggedWith` "nested"+ <|> queryPrefixQuery+ `taggedWith` "prefix"+ <|> queryRangeQuery+ `taggedWith` "range"+ <|> queryRegexpQuery+ `taggedWith` "regexp"+ <|> querySimpleQueryStringQuery+ `taggedWith` "simple_query_string"+ <|> queryWildcardQuery+ `taggedWith` "wildcard" where taggedWith parser k = parser =<< o .: k termQuery = fieldTagged $ \(FieldName fn) o ->@@ -181,7 +207,8 @@ queryCommonTermsQuery = pure . QueryCommonTermsQuery constantScoreQuery o = case X.lookup "filter" o of Just x ->- ConstantScoreQuery <$> parseJSON x+ ConstantScoreQuery+ <$> parseJSON x <*> o .: "boost" _ -> fail "Does not appear to be a ConstantScoreQuery" queryFunctionScoreQuery = pure . QueryFunctionScoreQuery@@ -329,7 +356,8 @@ parseJSON = withObject "SimpleQueryStringQuery" parse where parse o =- SimpleQueryStringQuery <$> o .: "query"+ SimpleQueryStringQuery+ <$> o .: "query" <*> o .:? "fields" <*> o .:? "default_operator" <*> o .:? "analyzer"@@ -1614,9 +1642,12 @@ parseJSON = withObject "BoolMatch" parse where parse o =- mustMatch `taggedWith` "must"- <|> mustNotMatch `taggedWith` "must_not"- <|> shouldMatch `taggedWith` "should"+ mustMatch+ `taggedWith` "must"+ <|> mustNotMatch+ `taggedWith` "must_not"+ <|> shouldMatch+ `taggedWith` "should" where taggedWith parser k = parser =<< o .: k mustMatch t = MustMatch t <$> o .:? "_cache" .!= defaultCache@@ -1657,7 +1688,8 @@ parseJSON = withObject "LatLon" parse where parse o =- LatLon <$> o .: "lat"+ LatLon+ <$> o .: "lat" <*> o .: "lon" data GeoBoundingBox = GeoBoundingBox@@ -1816,7 +1848,8 @@ parseJSON = withText "Distance" parse where parse t =- Distance <$> parseCoeff nT+ Distance+ <$> parseCoeff nT <*> parseJSON (String unitT) where (nT, unitT) = T.span validForNumber t@@ -1890,14 +1923,14 @@ omitNulls base where base =- functionScoreFunctionsPair fns :- [ "query" .= query,- "boost" .= boost,- "max_boost" .= maxBoost,- "boost_mode" .= boostMode,- "min_score" .= minScore,- "score_mode" .= scoreMode- ]+ functionScoreFunctionsPair fns+ : [ "query" .= query,+ "boost" .= boost,+ "max_boost" .= maxBoost,+ "boost_mode" .= boostMode,+ "min_score" .= minScore,+ "score_mode" .= scoreMode+ ] instance FromJSON FunctionScoreQuery where parseJSON = withObject "FunctionScoreQuery" parse@@ -1907,7 +1940,8 @@ <$> o .:? "query" <*> o .:? "boost" <*> ( singleFunction o- <|> multipleFunctions `taggedWith` "functions"+ <|> multipleFunctions+ `taggedWith` "functions" ) <*> o .:? "max_boost" <*> o .:? "boost_mode"@@ -1935,10 +1969,10 @@ omitNulls base where base =- functionScoreFunctionPair fn :- [ "filter" .= filter',- "weight" .= weight- ]+ functionScoreFunctionPair fn+ : [ "filter" .= filter',+ "weight" .= weight+ ] instance FromJSON ComponentFunctionScoreFunction where parseJSON = withObject "ComponentFunctionScoreFunction" parse
tests/Test/BulkAPI.hs view
@@ -44,7 +44,8 @@ assertDocs as = do let (ids, docs) = unzip as res <-- ids & traverse (getDocument testIndex)+ ids+ & traverse (getDocument testIndex) <&> traverse (fmap getSource . eitherDecodeResponse) liftIO $ res `shouldBe` Right (Just <$> docs)
tests/Test/Generators.hs view
@@ -48,7 +48,8 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where arbitrary =- Hit <$> arbitrary+ Hit+ <$> arbitrary <*> arbitrary <*> arbitraryScore <*> arbitrary@@ -492,7 +493,9 @@ . chomp <$> arbitrary, CharFilterDefinitionPatternReplace- <$> arbitrary <*> arbitrary <*> arbitrary+ <$> arbitrary+ <*> arbitrary+ <*> arbitrary ] where chomp =
tests/Test/Snapshots.hs view
@@ -90,7 +90,7 @@ Right [snap] | snapInfoState snap == SnapshotSuccess && snapInfoName snap == s1n ->- return ()+ return () | otherwise -> expectationFailure (show snap) Right [] -> expectationFailure "There were no snapshots" Right snaps -> expectationFailure ("Expected 1 snapshot but got" <> show (length snaps))
tests/tests.hs view
@@ -67,7 +67,8 @@ Just dv -> (dv >= minBound) .&&. (dv <= maxBound)- .&&. docVersionNumber dv === i+ .&&. docVersionNumber dv+ === i describe "getNodesInfo" $ it "fetches the responding node when LocalNode is used" $