git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #143 from 23Skidoo/patch-1
255e39eChris Allen
.gitignore+2
@@ -1,9 +1,11 @@
1cabal.sandbox.config
1cabal.sandbox.config
2.cabal-sandbox/
2.cabal-sandbox/
3dist/
3dist/
4+dist-newstyle/
4.project
5.project
5.dist-buildwrapper/
6.dist-buildwrapper/
6.DS_Store
7.DS_Store
8+TAGS
7*.hi
9*.hi
8*.o
10*.o
9bloodhound-*-docs/
11bloodhound-*-docs/
README.md+3−4
@@ -181,10 +181,9 @@ data TweetMapping = TweetMapping deriving (Eq, Show)
181:{
181:{
182instance ToJSON TweetMapping where
182instance ToJSON TweetMapping where
183 toJSON TweetMapping =
183 toJSON TweetMapping =
184− object ["tweet" .=
184+ object ["properties" .=
185− object ["properties" .=
185+ object ["location" .=
186− object ["location" .=
187− object ["type" .= ("geo_point" :: Text)]]]]
186+ object ["type" .= ("geo_point" :: Text)]]]
188:}
187:}
189
188
190resp <- withBH' $ putMapping testIndex testMapping TweetMapping
189resp <- withBH' $ putMapping testIndex testMapping TweetMapping
src/Database/Bloodhound/Client.hs+3−4
@@ -140,10 +140,9 @@ import Database.Bloodhound.Types
140-- >>> :{
140-- >>> :{
141--instance ToJSON TweetMapping where
141--instance ToJSON TweetMapping where
142-- toJSON TweetMapping =
142-- toJSON TweetMapping =
143−-- object ["tweet" .=
143+-- object ["properties" .=
144−-- object ["properties" .=
144+-- object ["location" .=
145−-- object ["location" .=
146−-- object ["type" .= ("geo_point" :: Text)]]]]
145+-- object ["type" .= ("geo_point" :: Text)]]]
147--data Location = Location { lat :: Double
146--data Location = Location { lat :: Double
148-- , lon :: Double } deriving (Eq, Generic, Show)
147-- , lon :: Double } deriving (Eq, Generic, Show)
149--data Tweet = Tweet { user :: Text
148--data Tweet = Tweet { user :: Text
tests/tests.hs+30−31
@@ -177,47 +177,44 @@ data ParentMapping = ParentMapping deriving (Eq, Show)
177
177
178instance ToJSON ParentMapping where
178instance ToJSON ParentMapping where
179 toJSON ParentMapping =
179 toJSON ParentMapping =
180− object ["parent" .=
181− object ["properties" .=
180+ object ["properties" .=
182− object [ "user" .= object ["type" .= ("string" :: Text)]
181+ object [ "user" .= object ["type" .= ("string" :: Text)]
183− -- Serializing the date as a date is breaking other tests, mysteriously.
182+ -- Serializing the date as a date is breaking other tests, mysteriously.
184− -- , "postDate" .= object [ "type" .= ("date" :: Text)
183+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
185− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
184+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
186− , "message" .= object ["type" .= ("string" :: Text)]
185+ , "message" .= object ["type" .= ("string" :: Text)]
187− , "age" .= object ["type" .= ("integer" :: Text)]
186+ , "age" .= object ["type" .= ("integer" :: Text)]
188− , "location" .= object ["type" .= ("geo_point" :: Text)]
187+ , "location" .= object ["type" .= ("geo_point" :: Text)]
189− ]]]
188+ ]]
190
189
191data ChildMapping = ChildMapping deriving (Eq, Show)
190data ChildMapping = ChildMapping deriving (Eq, Show)
192
191
193instance ToJSON ChildMapping where
192instance ToJSON ChildMapping where
194 toJSON ChildMapping =
193 toJSON ChildMapping =
195− object ["child" .=
196− object ["_parent" .= object ["type" .= ("parent" :: Text)]
194+ object ["_parent" .= object ["type" .= ("parent" :: Text)]
197− , "properties" .=
195+ , "properties" .=
198− object [ "user" .= object ["type" .= ("string" :: Text)]
196+ object [ "user" .= object ["type" .= ("string" :: Text)]
199− -- Serializing the date as a date is breaking other tests, mysteriously.
197+ -- Serializing the date as a date is breaking other tests, mysteriously.
200− -- , "postDate" .= object [ "type" .= ("date" :: Text)
198+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
201− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
199+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
202− , "message" .= object ["type" .= ("string" :: Text)]
200+ , "message" .= object ["type" .= ("string" :: Text)]
203− , "age" .= object ["type" .= ("integer" :: Text)]
201+ , "age" .= object ["type" .= ("integer" :: Text)]
204− , "location" .= object ["type" .= ("geo_point" :: Text)]
202+ , "location" .= object ["type" .= ("geo_point" :: Text)]
205− ]]]
203+ ]]
206
204
207data TweetMapping = TweetMapping deriving (Eq, Show)
205data TweetMapping = TweetMapping deriving (Eq, Show)
208
206
209instance ToJSON TweetMapping where
207instance ToJSON TweetMapping where
210 toJSON TweetMapping =
208 toJSON TweetMapping =
211− object ["tweet" .=
212− object ["properties" .=
209+ object ["properties" .=
213− object [ "user" .= object ["type" .= ("string" :: Text)]
210+ object [ "user" .= object ["type" .= ("string" :: Text)]
214− -- Serializing the date as a date is breaking other tests, mysteriously.
211+ -- Serializing the date as a date is breaking other tests, mysteriously.
215− -- , "postDate" .= object [ "type" .= ("date" :: Text)
212+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
216− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
213+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
217− , "message" .= object ["type" .= ("string" :: Text)]
214+ , "message" .= object ["type" .= ("string" :: Text)]
218− , "age" .= object ["type" .= ("integer" :: Text)]
215+ , "age" .= object ["type" .= ("integer" :: Text)]
219− , "location" .= object ["type" .= ("geo_point" :: Text)]
216+ , "location" .= object ["type" .= ("geo_point" :: Text)]
220− ]]]
217+ ]]
221
218
222exampleTweet :: Tweet
219exampleTweet :: Tweet
223exampleTweet = Tweet { user = "bitemyapp"
220exampleTweet = Tweet { user = "bitemyapp"
@@ -623,8 +620,10 @@ instance Arbitrary Day where
623 arbitrary = ModifiedJulianDay <$> (2000 +) <$> arbitrary
620 arbitrary = ModifiedJulianDay <$> (2000 +) <$> arbitrary
624 shrink = (ModifiedJulianDay <$>) . shrink . toModifiedJulianDay
621 shrink = (ModifiedJulianDay <$>) . shrink . toModifiedJulianDay
625
622
623+#if !MIN_VERSION_QuickCheck(2,9,0)
626instance Arbitrary a => Arbitrary (NonEmpty a) where
624instance Arbitrary a => Arbitrary (NonEmpty a) where
627 arbitrary = liftA2 (:|) arbitrary arbitrary
625 arbitrary = liftA2 (:|) arbitrary arbitrary
626+#endif
628
627
629arbitraryScore :: Gen Score
628arbitraryScore :: Gen Score
630arbitraryScore = fmap getPositive <$> arbitrary
629arbitraryScore = fmap getPositive <$> arbitrary