git.iko.soy/typeable/bloodhound
on master help sign in
IdsFilter w/ validation
631b863Chris Allen
Database/Bloodhound/Client.hs+6
@@ -375,6 +375,7 @@ data Filter = AndFilter [Filter] Cache
375 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
375 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
376 | GeoDistanceRangeFilter GeoPoint DistanceRange
376 | GeoDistanceRangeFilter GeoPoint DistanceRange
377 | GeoPolygonFilter FieldName [LatLon]
377 | GeoPolygonFilter FieldName [LatLon]
378+ | IdsFilter MappingName [DocumentID]
378 deriving (Eq, Show)
379 deriving (Eq, Show)
379
380
380class Monoid a => Seminearring a where
381class Monoid a => Seminearring a where
@@ -437,6 +438,11 @@ instance ToJSON Filter where
437 object [geoField .=
438 object [geoField .=
438 object ["points" .= fmap toJSON latLons]]]
439 object ["points" .= fmap toJSON latLons]]]
439
440
441+ toJSON (IdsFilter mappingName values) =
442+ object ["ids" .=
443+ object ["type" .= mappingName
444+ , "values" .= fmap T.pack values]]
445+
440instance ToJSON GeoPoint where
446instance ToJSON GeoPoint where
441 toJSON (GeoPoint geoField latLon) =
447 toJSON (GeoPoint geoField latLon) =
442 object [geoField .= toJSON latLon]
448 object [geoField .= toJSON latLon]
README.org+17−1
@@ -6,7 +6,23 @@ Elasticsearch client and query DSL for Haskell
6
6
7** Possible future functionality
7** Possible future functionality
8
8
9+*** GeoShapeFilter
10+
11+http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
12+
13+*** Geohash cell filter
14+
15+http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-filter.html
16+
17+*** HasChild Filter
18+
19+http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
20+
21+*** HasParent Filter
22+
23+http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-parent-filter.html
24+
9−Runtime checking for cycles in data structures:
25+*** Runtime checking for cycles in data structures
10
26
11check for n > 1 occurrences in DFS:
27check for n > 1 occurrences in DFS:
12
28
tests/tests.hs+7
@@ -178,3 +178,10 @@ main = hspec $ do
178 let geoFilter = GeoPolygonFilter "tweet.location" points
178 let geoFilter = GeoPolygonFilter "tweet.location" points
179 let search = Search Nothing (Just geoFilter)
179 let search = Search Nothing (Just geoFilter)
180 searchExpectNoResults search
180 searchExpectNoResults search
181+
182+ it "returns document for ids filter" $ do
183+ _ <- insertData
184+ let filter = IdsFilter "tweet" ["1"]
185+ let search = Search Nothing (Just filter)
186+ myTweet <- searchTweet search
187+ myTweet `shouldBe` Right exampleTweet