git.iko.soy/typeable/bloodhound
on master help sign in
add V1 support, fix tests
1454d69Josh Berman
bloodhound.cabal+1−1
@@ -1,5 +1,5 @@
1name: bloodhound
1name: bloodhound
2−version: 0.15.1.0
2+version: 0.16.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
5homepage: https://github.com/bitemyapp/bloodhound
5homepage: https://github.com/bitemyapp/bloodhound
src/Database/V1/Bloodhound/Types.hs+72−1
@@ -333,6 +333,9 @@ module Database.V1.Bloodhound.Types
333 , SuggestOptions(..)
333 , SuggestOptions(..)
334 , SuggestResponse(..)
334 , SuggestResponse(..)
335 , NamedSuggestionResponse(..)
335 , NamedSuggestionResponse(..)
336+ , DirectGenerators(..)
337+ , mkDirectGenerators
338+ , DirectGeneratorSuggestModeTypes (..)
336
339
337 , Aggregation(..)
340 , Aggregation(..)
338 , Aggregations
341 , Aggregations
@@ -5382,6 +5385,7 @@ data PhraseSuggester =
5382 , phraseSuggesterShardSize :: Maybe Int
5385 , phraseSuggesterShardSize :: Maybe Int
5383 , phraseSuggesterHighlight :: Maybe PhraseSuggesterHighlighter
5386 , phraseSuggesterHighlight :: Maybe PhraseSuggesterHighlighter
5384 , phraseSuggesterCollate :: Maybe PhraseSuggesterCollate
5387 , phraseSuggesterCollate :: Maybe PhraseSuggesterCollate
5388+ , phraseSuggesterCandidateGenerators :: [DirectGenerators]
5385 }
5389 }
5386 deriving (Show, Generic, Eq, Read, Typeable)
5390 deriving (Show, Generic, Eq, Read, Typeable)
5387
5391
@@ -5397,6 +5401,7 @@ instance ToJSON PhraseSuggester where
5397 , "shard_size" .= phraseSuggesterShardSize
5401 , "shard_size" .= phraseSuggesterShardSize
5398 , "highlight" .= phraseSuggesterHighlight
5402 , "highlight" .= phraseSuggesterHighlight
5399 , "collate" .= phraseSuggesterCollate
5403 , "collate" .= phraseSuggesterCollate
5404+ , "direct_generator" .= phraseSuggesterCandidateGenerators
5400 ]
5405 ]
5401
5406
5402instance FromJSON PhraseSuggester where
5407instance FromJSON PhraseSuggester where
@@ -5413,11 +5418,12 @@ instance FromJSON PhraseSuggester where
5413 <*> o .:? "shard_size"
5418 <*> o .:? "shard_size"
5414 <*> o .:? "highlight"
5419 <*> o .:? "highlight"
5415 <*> o .:? "collate"
5420 <*> o .:? "collate"
5421+ <*> o .:? "direct_generator" .!= []
5416
5422
5417mkPhraseSuggester :: FieldName -> PhraseSuggester
5423mkPhraseSuggester :: FieldName -> PhraseSuggester
5418mkPhraseSuggester fName =
5424mkPhraseSuggester fName =
5419 PhraseSuggester fName Nothing Nothing Nothing Nothing Nothing Nothing
5425 PhraseSuggester fName Nothing Nothing Nothing Nothing Nothing Nothing
5420− Nothing Nothing Nothing Nothing
5426+ Nothing Nothing Nothing Nothing []
5421
5427
5422data PhraseSuggesterHighlighter =
5428data PhraseSuggesterHighlighter =
5423 PhraseSuggesterHighlighter { phraseSuggesterHighlighterPreTag :: Text
5429 PhraseSuggesterHighlighter { phraseSuggesterHighlighterPreTag :: Text
@@ -5507,3 +5513,68 @@ instance FromJSON NamedSuggestionResponse where
5507 return $ NamedSuggestionResponse suggestionName' suggestionResponses'
5513 return $ NamedSuggestionResponse suggestionName' suggestionResponses'
5508
5514
5509 parseJSON x = typeMismatch "NamedSuggestionResponse" x
5515 parseJSON x = typeMismatch "NamedSuggestionResponse" x
5516+
5517+data DirectGeneratorSuggestModeTypes = DirectGeneratorSuggestModeMissing
5518+ | DirectGeneratorSuggestModePopular
5519+ | DirectGeneratorSuggestModeAlways
5520+ deriving (Show, Eq, Read, Generic)
5521+
5522+instance ToJSON DirectGeneratorSuggestModeTypes where
5523+ toJSON DirectGeneratorSuggestModeMissing = "missing"
5524+ toJSON DirectGeneratorSuggestModePopular = "popular"
5525+ toJSON DirectGeneratorSuggestModeAlways = "always"
5526+
5527+instance FromJSON DirectGeneratorSuggestModeTypes where
5528+ parseJSON = withText "DirectGeneratorSuggestModeTypes" parse
5529+ where parse "missing" = pure DirectGeneratorSuggestModeMissing
5530+ parse "popular" = pure DirectGeneratorSuggestModePopular
5531+ parse "always" = pure DirectGeneratorSuggestModeAlways
5532+ parse f = fail ("Unexpected DirectGeneratorSuggestModeTypes: " <> show f)
5533+
5534+data DirectGenerators = DirectGenerators
5535+ { directGeneratorsField :: FieldName
5536+ , directGeneratorsSize :: Maybe Int
5537+ , directGeneratorSuggestMode :: DirectGeneratorSuggestModeTypes
5538+ , directGeneratorMaxEdits :: Maybe Double
5539+ , directGeneratorPrefixLength :: Maybe Int
5540+ , directGeneratorMinWordLength :: Maybe Int
5541+ , directGeneratorMaxInspections :: Maybe Int
5542+ , directGeneratorMinDocFreq :: Maybe Double
5543+ , directGeneratorMaxTermFreq :: Maybe Double
5544+ , directGeneratorPreFilter :: Maybe Text
5545+ , directGeneratorPostFilter :: Maybe Text
5546+ }
5547+ deriving (Show, Eq, Read, Generic)
5548+
5549+
5550+instance ToJSON DirectGenerators where
5551+ toJSON DirectGenerators{..} = omitNulls [ "field" .= directGeneratorsField
5552+ , "size" .= directGeneratorsSize
5553+ , "suggest_mode" .= directGeneratorSuggestMode
5554+ , "max_edits" .= directGeneratorMaxEdits
5555+ , "prefix_length" .= directGeneratorPrefixLength
5556+ , "min_word_length" .= directGeneratorMinWordLength
5557+ , "max_inspections" .= directGeneratorMaxInspections
5558+ , "min_doc_freq" .= directGeneratorMinDocFreq
5559+ , "max_term_freq" .= directGeneratorMaxTermFreq
5560+ , "pre_filter" .= directGeneratorPreFilter
5561+ , "post_filter" .= directGeneratorPostFilter
5562+ ]
5563+
5564+instance FromJSON DirectGenerators where
5565+ parseJSON = withObject "DirectGenerators" parse
5566+ where parse o = DirectGenerators
5567+ <$> o .: "field"
5568+ <*> o .:? "size"
5569+ <*> o .: "suggest_mode"
5570+ <*> o .:? "max_edits"
5571+ <*> o .:? "prefix_length"
5572+ <*> o .:? "min_word_length"
5573+ <*> o .:? "max_inspections"
5574+ <*> o .:? "min_doc_freq"
5575+ <*> o .:? "max_term_freq"
5576+ <*> o .:? "pre_filter"
5577+ <*> o .:? "post_filter"
5578+
5579+mkDirectGenerators :: FieldName -> DirectGenerators
5580+mkDirectGenerators fn = DirectGenerators fn Nothing DirectGeneratorSuggestModeMissing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
src/Database/V5/Bloodhound/Types.hs+1−1
@@ -5429,7 +5429,7 @@ data DirectGeneratorSuggestModeTypes = DirectGeneratorSuggestModeMissing
5429 | DirectGeneratorSuggestModePopular
5429 | DirectGeneratorSuggestModePopular
5430 | DirectGeneratorSuggestModeAlways
5430 | DirectGeneratorSuggestModeAlways
5431 deriving (Show, Eq, Read, Generic)
5431 deriving (Show, Eq, Read, Generic)
5432−
5432+
5433instance ToJSON DirectGeneratorSuggestModeTypes where
5433instance ToJSON DirectGeneratorSuggestModeTypes where
5434 toJSON DirectGeneratorSuggestModeMissing = "missing"
5434 toJSON DirectGeneratorSuggestModeMissing = "missing"
5435 toJSON DirectGeneratorSuggestModePopular = "popular"
5435 toJSON DirectGeneratorSuggestModePopular = "popular"
stack-8.0.yaml+2−2
@@ -5,13 +5,13 @@ flags:
5packages:
5packages:
6- '.'
6- '.'
7- './examples'
7- './examples'
8−# extra-deps:
8+extra-deps:
9# - http-client-0.5.0
9# - http-client-0.5.0
10# - aeson-1.2.0.0
10# - aeson-1.2.0.0
11# - fail-4.9.0.0
11# - fail-4.9.0.0
12# - http-types-0.9
12# - http-types-0.9
13# - attoparsec-0.13.0.1
13# - attoparsec-0.13.0.1
14−# - quickcheck-properties-0.1
14+- quickcheck-properties-0.1
15# - semigroups-0.18.3
15# - semigroups-0.18.3
16# - uri-bytestring-0.1.9
16# - uri-bytestring-0.1.9
17# - temporary-resourcet-0.1.0.0
17# - temporary-resourcet-0.1.0.0
stack-8.2.yaml+3
@@ -6,4 +6,7 @@ packages:
6 - '.'
6 - '.'
7 - './examples'
7 - './examples'
8
8
9+extra-deps:
10+- quickcheck-properties-0.1
11+
9resolver: lts-10.0
12resolver: lts-10.0
tests/V1/tests.hs+6
@@ -607,6 +607,8 @@ instance ApproxEq PhraseSuggesterCollate
607instance ApproxEq PhraseSuggester
607instance ApproxEq PhraseSuggester
608instance ApproxEq SuggestType
608instance ApproxEq SuggestType
609instance ApproxEq Suggest
609instance ApproxEq Suggest
610+instance ApproxEq DirectGenerators
611+instance ApproxEq DirectGeneratorSuggestModeTypes
610
612
611-- | Due to the way nodeattrfilters get serialized here, they may come
613-- | Due to the way nodeattrfilters get serialized here, they may come
612-- out in a different order, but they are morally equivalent
614-- out in a different order, but they are morally equivalent
@@ -937,6 +939,8 @@ instance Arbitrary Size where arbitrary = sopArbitrary; shrink = genericShrink
937instance Arbitrary PhraseSuggester where arbitrary = sopArbitrary; shrink = genericShrink
939instance Arbitrary PhraseSuggester where arbitrary = sopArbitrary; shrink = genericShrink
938instance Arbitrary SuggestType where arbitrary = sopArbitrary; shrink = genericShrink
940instance Arbitrary SuggestType where arbitrary = sopArbitrary; shrink = genericShrink
939instance Arbitrary Suggest where arbitrary = sopArbitrary; shrink = genericShrink
941instance Arbitrary Suggest where arbitrary = sopArbitrary; shrink = genericShrink
942+instance Arbitrary DirectGenerators where arbitrary = sopArbitrary; shrink = genericShrink
943+instance Arbitrary DirectGeneratorSuggestModeTypes where arbitrary = sopArbitrary; shrink = genericShrink
940
944
941newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
945newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
942 deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
946 deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
@@ -1933,6 +1937,8 @@ main = hspec $ do
1933 propJSON (Proxy :: Proxy CompoundFormat)
1937 propJSON (Proxy :: Proxy CompoundFormat)
1934 propJSON (Proxy :: Proxy TemplateQueryInline)
1938 propJSON (Proxy :: Proxy TemplateQueryInline)
1935 propJSON (Proxy :: Proxy Suggest)
1939 propJSON (Proxy :: Proxy Suggest)
1940+ propJSON (Proxy :: Proxy DirectGenerators)
1941+ propJSON (Proxy :: Proxy DirectGeneratorSuggestModeTypes)
1936
1942
1937-- Temporary solution for lacking of generic derivation of Arbitrary
1943-- Temporary solution for lacking of generic derivation of Arbitrary
1938-- We use generics-sop, as it's much more concise than directly using GHC.Generics
1944-- We use generics-sop, as it's much more concise than directly using GHC.Generics