git.iko.soy/typeable/bloodhound
on master help sign in
Fixed GeoBoundingBoxFilter to have the GeoFilterType in the correct

position. Tested on ES 1.0.1 and 1.3.2

commitcb80f47021f9618b423d80a9008b115fc27e0795 authorCurtis Carter <curtis@rubyhq.com> dateFri 15 Aug 2014, 13:39 (12 years ago) parentcaecf0f
3 files changed+14−16
Database/Bloodhound/Types.hs+8−7 README.org+2−5 tests/tests.hs+4−4
Database/Bloodhound/Types.hs+8−7
@@ -796,7 +796,7 @@ data Filter = AndFilter [Filter] Cache
796796 | IdentityFilter
797797 | BoolFilter BoolMatch
798798 | ExistsFilter FieldName -- always cached
799− | GeoBoundingBoxFilter GeoBoundingBoxConstraint GeoFilterType
799+ | GeoBoundingBoxFilter GeoBoundingBoxConstraint
800800 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
801801 | GeoDistanceRangeFilter GeoPoint DistanceRange
802802 | GeoPolygonFilter FieldName [LatLon]
@@ -880,6 +880,7 @@ data GeoBoundingBoxConstraint =
880880 GeoBoundingBoxConstraint { geoBBField :: FieldName
881881 , constraintBox :: GeoBoundingBox
882882 , bbConstraintcache :: Cache
883+ , geoType :: GeoFilterType
883884 } deriving (Eq, Show)
884885
885886data GeoPoint =
@@ -977,9 +978,8 @@ instance ToJSON Filter where
977978 toJSON (BoolFilter boolMatch) =
978979 object ["bool" .= toJSON boolMatch]
979980
980− toJSON (GeoBoundingBoxFilter bbConstraint filterType) =
981− object ["geo_bounding_box" .= toJSON bbConstraint
982− , "type" .= toJSON filterType]
981+ toJSON (GeoBoundingBoxFilter bbConstraint) =
982+ object ["geo_bounding_box" .= toJSON bbConstraint]
983983
984984 toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) geoDistLatLon)
985985 distance distanceType optimizeBbox cache) =
@@ -1283,7 +1283,7 @@ instance ToJSON MoreLikeThisQuery where
12831283 mtf mqt stopwords mindf maxdf
12841284 minwl maxwl boostTerms boost analyzer) =
12851285 omitNulls base
1286− where base = [ "like_text" .= toJSON text
1286+ where base = [ "like_text" .= toJSON text
12871287 , "fields" .= fields
12881288 , "percent_terms_to_match" .= percent
12891289 , "min_term_freq" .= mtf
@@ -1617,9 +1617,10 @@ instance ToJSON OptimizeBbox where
16171617
16181618instance ToJSON GeoBoundingBoxConstraint where
16191619 toJSON (GeoBoundingBoxConstraint
1620− (FieldName gbbcGeoBBField) gbbcConstraintBox cache) =
1620+ (FieldName gbbcGeoBBField) gbbcConstraintBox cache type') =
16211621 object [gbbcGeoBBField .= toJSON gbbcConstraintBox
1622− , "_cache" .= cache]
1622+ , "_cache" .= cache
1623+ , "type" .= type']
16231624
16241625
16251626instance ToJSON GeoFilterType where
README.org+2−5
@@ -212,7 +212,7 @@ resp <- indexDocument testServer testIndex testMapping exampleTweet (DocId "1")
212212
213213Response {responseStatus =
214214 Status {statusCode = 200, statusMessage = "OK"}
215− , responseVersion = HTTP/1.1, responseHeaders =
215+ , responseVersion = HTTP/1.1, responseHeaders =
216216 [("Content-Type","application/json; charset=UTF-8"),
217217 ("Content-Length","75")]
218218 , responseBody = "{\"_index\":\"twitter\",\"_type\":\"tweet\",\"_id\":\"1\",\"_version\":2,\"created\":false}"
@@ -479,10 +479,7 @@ let existsFilter = ExistsFilter (FieldName "user")
479479-- topLeft and bottomRight
480480let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
481481
482−let constraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
483−
484−-- second argument is GeoFilterType, memory or indexed.
485−let geoFilter = GeoBoundingBoxFilter constraint GeoFilterMemory
482+let constraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
486483
487484#+END_SRC
488485
tests/tests.hs+4−4
@@ -268,8 +268,8 @@ main = hspec $ do
268268 it "returns document for geo boundingbox filter" $ do
269269 _ <- insertData
270270 let box = GeoBoundingBox (LatLon 40.73 (-74.1)) (LatLon 40.10 (-71.12))
271− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
272− let geoFilter = GeoBoundingBoxFilter bbConstraint GeoFilterMemory
271+ let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
272+ let geoFilter = GeoBoundingBoxFilter bbConstraint
273273 let search = mkSearch Nothing (Just geoFilter)
274274 myTweet <- searchTweet search
275275 myTweet `shouldBe` Right exampleTweet
@@ -277,8 +277,8 @@ main = hspec $ do
277277 it "doesn't return document for nonsensical boundingbox filter" $ do
278278 _ <- insertData
279279 let box = GeoBoundingBox (LatLon 0.73 (-4.1)) (LatLon 0.10 (-1.12))
280− let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False
281− let geoFilter = GeoBoundingBoxFilter bbConstraint GeoFilterMemory
280+ let bbConstraint = GeoBoundingBoxConstraint (FieldName "tweet.location") box False GeoFilterMemory
281+ let geoFilter = GeoBoundingBoxFilter bbConstraint
282282 let search = mkSearch Nothing (Just geoFilter)
283283 searchExpectNoResults search
284284