git.iko.soy/typeable/bloodhound
on master help sign in
warning squashing, terms query
610c4c8Chris Allen
Database/Bloodhound/Types/Instances.hs+16−11
@@ -50,25 +50,25 @@ instance ToJSON Filter where
50 object ["geo_bounding_box" .= toJSON bbConstraint
50 object ["geo_bounding_box" .= toJSON bbConstraint
51 , "type" .= toJSON filterType]
51 , "type" .= toJSON filterType]
52
52
53− toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) latLon)
53+ toJSON (GeoDistanceFilter (GeoPoint (FieldName distanceGeoField) geoDistLatLon)
54 distance distanceType optimizeBbox cache) =
54 distance distanceType optimizeBbox cache) =
55 object ["geo_distance" .=
55 object ["geo_distance" .=
56 object ["distance" .= toJSON distance
56 object ["distance" .= toJSON distance
57 , "distance_type" .= toJSON distanceType
57 , "distance_type" .= toJSON distanceType
58 , "optimize_bbox" .= optimizeBbox
58 , "optimize_bbox" .= optimizeBbox
59− , distanceGeoField .= toJSON latLon
59+ , distanceGeoField .= toJSON geoDistLatLon
60 , "_cache" .= cache]]
60 , "_cache" .= cache]]
61
61
62 toJSON (GeoDistanceRangeFilter (GeoPoint (FieldName gddrField) drLatLon)
62 toJSON (GeoDistanceRangeFilter (GeoPoint (FieldName gddrField) drLatLon)
63− (DistanceRange distanceFrom drDistanceTo)) =
63+ (DistanceRange geoDistRangeDistFrom drDistanceTo)) =
64 object ["geo_distance_range" .=
64 object ["geo_distance_range" .=
65− object ["from" .= toJSON distanceFrom
65+ object ["from" .= toJSON geoDistRangeDistFrom
66 , "to" .= toJSON drDistanceTo
66 , "to" .= toJSON drDistanceTo
67 , gddrField .= toJSON drLatLon]]
67 , gddrField .= toJSON drLatLon]]
68
68
69− toJSON (GeoPolygonFilter (FieldName geoField) latLons) =
69+ toJSON (GeoPolygonFilter (FieldName geoPolygonFilterField) latLons) =
70 object ["geo_polygon" .=
70 object ["geo_polygon" .=
71− object [geoField .=
71+ object [geoPolygonFilterField .=
72 object ["points" .= fmap toJSON latLons]]]
72 object ["points" .= fmap toJSON latLons]]]
73
73
74 toJSON (IdsFilter (MappingName mappingName) values) =
74 toJSON (IdsFilter (MappingName mappingName) values) =
@@ -120,19 +120,24 @@ instance ToJSON Filter where
120 , "_cache_key" .= cacheKey]]
120 , "_cache_key" .= cacheKey]]
121
121
122instance ToJSON GeoPoint where
122instance ToJSON GeoPoint where
123− toJSON (GeoPoint (FieldName geoField) latLon) =
123+ toJSON (GeoPoint (FieldName geoPointField) geoPointLatLon) =
124− object [ geoField .= toJSON latLon ]
124+ object [ geoPointField .= toJSON geoPointLatLon ]
125
125
126
126
127instance ToJSON Query where
127instance ToJSON Query where
128− toJSON (TermQuery (Term termField termValue) boost) =
128+ toJSON (TermQuery (Term termQueryField termQueryValue) boost) =
129 object [ "term" .=
129 object [ "term" .=
130− object [termField .= object merged]]
130+ object [termQueryField .= object merged]]
131 where
131 where
132− base = [ "value" .= termValue ]
132+ base = [ "value" .= termQueryValue ]
133 boosted = maybe [] (return . ("boost" .=)) boost
133 boosted = maybe [] (return . ("boost" .=)) boost
134 merged = mappend base boosted
134 merged = mappend base boosted
135
135
136+ toJSON (TermsQuery terms termsQueryMinimumMatch) =
137+ object [ "terms" .= object conjoined ]
138+ where conjoined = [ "tags" .= fmap toJSON terms
139+ , "minimum_should_match" .= toJSON termsQueryMinimumMatch ]
140+
136 toJSON (QueryMatchQuery matchQuery) =
141 toJSON (QueryMatchQuery matchQuery) =
137 object [ "match" .= toJSON matchQuery ]
142 object [ "match" .= toJSON matchQuery ]
138
143