git.iko.soy/typeable/bloodhound
on master help sign in
IdsFilter w/ validation
commit631b8631e65c2a7eab934488ad9c1f92d8f98211 authorChris Allen <cma@bitemyapp.com> dateThu 10 Apr 2014, 20:04 (13 years ago) parenta800719
3 files changed+30−1
Database/Bloodhound/Client.hs+6 README.org+17−1 tests/tests.hs+7
Database/Bloodhound/Client.hs+6
@@ -375,6 +375,7 @@ data Filter = AndFilter [Filter] Cache
375375 | GeoDistanceFilter GeoPoint Distance DistanceType OptimizeBbox Cache
376376 | GeoDistanceRangeFilter GeoPoint DistanceRange
377377 | GeoPolygonFilter FieldName [LatLon]
378+ | IdsFilter MappingName [DocumentID]
378379 deriving (Eq, Show)
379380
380381class Monoid a => Seminearring a where
@@ -437,6 +438,11 @@ instance ToJSON Filter where
437438 object [geoField .=
438439 object ["points" .= fmap toJSON latLons]]]
439440
441+ toJSON (IdsFilter mappingName values) =
442+ object ["ids" .=
443+ object ["type" .= mappingName
444+ , "values" .= fmap T.pack values]]
445+
440446instance ToJSON GeoPoint where
441447 toJSON (GeoPoint geoField latLon) =
442448 object [geoField .= toJSON latLon]
README.org+17−1
@@ -6,7 +6,23 @@ Elasticsearch client and query DSL for Haskell
66
77** Possible future functionality
88
9−Runtime checking for cycles in data structures:
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+
25+*** Runtime checking for cycles in data structures
1026
1127check for n > 1 occurrences in DFS:
1228
tests/tests.hs+7
@@ -178,3 +178,10 @@ main = hspec $ do
178178 let geoFilter = GeoPolygonFilter "tweet.location" points
179179 let search = Search Nothing (Just geoFilter)
180180 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