@@ -29,22 +29,13 @@ instance ToJSON TweetMapping where
29 [ "properties" .=
29 [ "properties" .=
30 object ["location" .= object ["type" .= ("geo_point" :: Text)]]
30 object ["location" .= object ["type" .= ("geo_point" :: Text)]]
34−-------------------------------------------------------------------------------
35−data Location = Location
38− } deriving (Eq, Generic, Show)
41-------------------------------------------------------------------------------
32-------------------------------------------------------------------------------
42data Tweet = Tweet
33data Tweet = Tweet
43 { user :: Text
34 { user :: Text
44 , postDate :: UTCTime
35 , postDate :: UTCTime
45 , message :: Text
36 , message :: Text
46 , age :: Int
37 , age :: Int
47− , location :: Location
38+ , location :: LatLon
48 } deriving (Eq, Generic, Show)
39 } deriving (Eq, Generic, Show)
@@ -59,16 +50,12 @@ exampleTweet =
59 , location = loc
50 , location = loc
62− loc = Location {locLat = 40.12, locLon = (-71.34)}
53+ loc = LatLon {lat = 40.12, lon = -71.3}
64instance ToJSON Tweet where
55instance ToJSON Tweet where
65 toJSON = genericToJSON defaultOptions
56 toJSON = genericToJSON defaultOptions
66instance FromJSON Tweet where
57instance FromJSON Tweet where
67 parseJSON = genericParseJSON defaultOptions
58 parseJSON = genericParseJSON defaultOptions
68−instance ToJSON Location where
69− toJSON = genericToJSON defaultOptions
70−instance FromJSON Location where
71− parseJSON = genericParseJSON defaultOptions
74main :: IO ()
61main :: IO ()
@@ -117,7 +104,7 @@ main = runBH' $ do
118 return ()
105 return ()
120− testServer = (Server "http://localhost:9200")
107+ testServer = Server "http://localhost:9200"
121 runBH' = withBH defaultManagerSettings testServer
108 runBH' = withBH defaultManagerSettings testServer
122 testIndex = IndexName "twitter"
109 testIndex = IndexName "twitter"
123 testMapping = MappingName "tweet"
110 testMapping = MappingName "tweet"