git.iko.soy/typeable/bloodhound
on master help sign in
Fixed GeoBoundingBoxFilter to have the GeoFilterType in the correct
cb80f47Curtis Carter
Database/Bloodhound/Types.hs+8−7
@@ -796,7 +796,7 @@ data Filter = AndFilter [Filter] Cache
796 | IdentityFilter
796 | IdentityFilter
797 | BoolFilter BoolMatch
797 | BoolFilter BoolMatch
798 | ExistsFilter FieldName -- always cached
798 | ExistsFilter FieldName -- always cached
799− | GeoBoundingBoxFilter GeoBoundingBoxConstraint GeoFilterType
799+ | GeoBoundingBoxFilter GeoBoundingBoxConstraint
800 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
800 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
801 | GeoDistanceRangeFilter GeoPoint DistanceRange
801 | GeoDistanceRangeFilter GeoPoint DistanceRange
802 | GeoPolygonFilter FieldName [LatLon]
802 | GeoPolygonFilter FieldName [LatLon]
@@ -880,6 +880,7 @@ data GeoBoundingBoxConstraint =
880 GeoBoundingBoxConstraint { geoBBField :: FieldName
880 GeoBoundingBoxConstraint { geoBBField :: FieldName
881 , constraintBox :: GeoBoundingBox
881 , constraintBox :: GeoBoundingBox
882 , bbConstraintcache :: Cache
882 , bbConstraintcache :: Cache
883+ , geoType :: GeoFilterType
883 } deriving (Eq, Show)
884 } deriving (Eq, Show)
884
885
885data GeoPoint =
886data GeoPoint =
@@ -977,9 +978,8 @@ instance ToJSON Filter where
977 toJSON (BoolFilter boolMatch) =
978 toJSON (BoolFilter boolMatch) =
978 object ["bool" .= toJSON boolMatch]
979 object ["bool" .= toJSON boolMatch]
979
980
980− toJSON (GeoBoundingBoxFilter bbConstraint filterType) =
981+ toJSON (GeoBoundingBoxFilter bbConstraint) =
981− object ["geo_bounding_box" .= toJSON bbConstraint
982+ object ["geo_bounding_box" .= toJSON bbConstraint]
982− , "type" .= toJSON filterType]
983
983
984 toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) geoDistLatLon)
984 toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) geoDistLatLon)
985 distance distanceType optimizeBbox cache) =
985 distance distanceType optimizeBbox cache) =
@@ -1283,7 +1283,7 @@ instance ToJSON MoreLikeThisQuery where
1283 mtf mqt stopwords mindf maxdf
1283 mtf mqt stopwords mindf maxdf
1284 minwl maxwl boostTerms boost analyzer) =
1284 minwl maxwl boostTerms boost analyzer) =
1285 omitNulls base
1285 omitNulls base
1286− where base = [ "like_text" .= toJSON text
1286+ where base = [ "like_text" .= toJSON text
1287 , "fields" .= fields
1287 , "fields" .= fields
1288 , "percent_terms_to_match" .= percent
1288 , "percent_terms_to_match" .= percent
1289 , "min_term_freq" .= mtf
1289 , "min_term_freq" .= mtf
@@ -1617,9 +1617,10 @@ instance ToJSON OptimizeBbox where
1617
1617
1618instance ToJSON GeoBoundingBoxConstraint where
1618instance ToJSON GeoBoundingBoxConstraint where
1619 toJSON (GeoBoundingBoxConstraint
1619 toJSON (GeoBoundingBoxConstraint
1620− (FieldName gbbcGeoBBField) gbbcConstraintBox cache) =
1620+ (FieldName gbbcGeoBBField) gbbcConstraintBox cache type') =
1621 object [gbbcGeoBBField .= toJSON gbbcConstraintBox
1621 object [gbbcGeoBBField .= toJSON gbbcConstraintBox
1622− , "_cache" .= cache]
1622+ , "_cache" .= cache
1623+ , "type" .= type']
1623
1624
1624
1625
1625instance ToJSON GeoFilterType where
1626instance ToJSON GeoFilterType where
README.org+2−5
@@ -212,7 +212,7 @@ resp <- indexDocument testServer testIndex testMapping exampleTweet (DocId "1")
212
212
213Response {responseStatus =
213Response {responseStatus =
214 Status {statusCode = 200, statusMessage = "OK"}
214 Status {statusCode = 200, statusMessage = "OK"}
215− , responseVersion = HTTP/1.1, responseHeaders =
215+ , responseVersion = HTTP/1.1, responseHeaders =
216 [("Content-Type","application/json; charset=UTF-8"),
216 [("Content-Type","application/json; charset=UTF-8"),
217 ("Content-Length","75")]
217 ("Content-Length","75")]
218 , responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":2,\"created\":false}"
218 , responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":2,\"created\":false}"
@@ -479,10 +479,7 @@ let existsFilter = ExistsFilter (FieldName "user")
479-- topLeft and bottomRight
479-- topLeft and bottomRight
480let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
480let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
481
481
482−let constraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
482+let constraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
483−
484−-- second argument is GeoFilterType, memory or indexed.
485−let geoFilter = GeoBoundingBoxFilter constraint GeoFilterMemory
486
483
487#+END_SRC
484#+END_SRC
488
485
tests/tests.hs+4−4
@@ -268,8 +268,8 @@ main = hspec $ do
268 it "returns document for geo boundingbox filter" $ do
268 it "returns document for geo boundingbox filter" $ do
269 _ <- insertData
269 _ <- insertData
270 let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
270 let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
271− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
271+ let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
272− let geoFilter = GeoBoundingBoxFilter bbConstraint GeoFilterMemory
272+ let geoFilter = GeoBoundingBoxFilter bbConstraint
273 let search = mkSearch Nothing (Just geoFilter)
273 let search = mkSearch Nothing (Just geoFilter)
274 myTweet <- searchTweet search
274 myTweet <- searchTweet search
275 myTweet `shouldBe` Right exampleTweet
275 myTweet `shouldBe` Right exampleTweet
@@ -277,8 +277,8 @@ main = hspec $ do
277 it "doesn't return document for nonsensical boundingbox filter" $ do
277 it "doesn't return document for nonsensical boundingbox filter" $ do
278 _ <- insertData
278 _ <- insertData
279 let box = GeoBoundingBox (LatLon 0.73 (-4.1)) (LatLon 0.10 (-1.12))
279 let box = GeoBoundingBox (LatLon 0.73 (-4.1)) (LatLon 0.10 (-1.12))
280− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
280+ let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
281− let geoFilter = GeoBoundingBoxFilter bbConstraint GeoFilterMemory
281+ let geoFilter = GeoBoundingBoxFilter bbConstraint
282 let search = mkSearch Nothing (Just geoFilter)
282 let search = mkSearch Nothing (Just geoFilter)
283 searchExpectNoResults search
283 searchExpectNoResults search
284
284