@@ -29,22 +29,13 @@ instance ToJSON TweetMapping where
2929 [ "properties" .=
3030 object ["location" .= object ["type" .= ("geo_point" :: Text)]]
3131 ]
32−
33−
34−-------------------------------------------------------------------------------
35−data Location = Location
36− { locLat :: Double
37− , locLon :: Double
38− } deriving (Eq, Generic, Show)
39−
40−
4132-------------------------------------------------------------------------------
4233data Tweet = Tweet
4334 { user :: Text
4435 , postDate :: UTCTime
4536 , message :: Text
4637 , age :: Int
47− , location :: Location
38+ , location :: LatLon
4839 } deriving (Eq, Generic, Show)
4940
5041
@@ -59,16 +50,12 @@ exampleTweet =
5950 , location = loc
6051 }
6152 where
62− loc = Location {locLat = 40.12, locLon = (-71.34)}
53+ loc = LatLon {lat = 40.12, lon = -71.3}
6354
6455instance ToJSON Tweet where
6556 toJSON = genericToJSON defaultOptions
6657instance FromJSON Tweet where
6758 parseJSON = genericParseJSON defaultOptions
68−instance ToJSON Location where
69− toJSON = genericToJSON defaultOptions
70−instance FromJSON Location where
71− parseJSON = genericParseJSON defaultOptions
7259
7360
7461main :: IO ()
@@ -117,7 +104,7 @@ main = runBH' $ do
117104
118105 return ()
119106 where
120− testServer = (Server "http://localhost:9200")
107+ testServer = Server "http://localhost:9200"
121108 runBH' = withBH defaultManagerSettings testServer
122109 testIndex = IndexName "twitter"
123110 testMapping = MappingName "tweet"