@@ -193,11 +193,22 @@ instance ToJSON Query where
193 toJSON (QueryNestedQuery query) =
193 toJSON (QueryNestedQuery query) =
194 object [ "nested" .= toJSON query ]
194 object [ "nested" .= toJSON query ]
196+ toJSON (QueryPrefixQuery query) =
197+ object [ "prefix" .= toJSON query ]
197mField :: (ToJSON a, Functor f) => T.Text -> f a -> f (T.Text, Value)
200mField :: (ToJSON a, Functor f) => T.Text -> f a -> f (T.Text, Value)
198mField field = fmap ((field .=) . toJSON)
201mField field = fmap ((field .=) . toJSON)
204+instance PrefixQuery where
205+ toJSON (PrefixQuery (FieldName fieldName) queryValue boost) =
206+ object [ fieldName .= object conjoined ]
207+ where base = [ "value" .= toJSON queryValue ]
208+ maybeAdd = [ mField "boost" boost ]
209+ conjoined = base ++ maybeAdd
201instance NestedQuery where
212instance NestedQuery where
202 toJSON (NestedQuery path scoreType query) =
213 toJSON (NestedQuery path scoreType query) =
203 object [ "path" .= toJSON path
214 object [ "path" .= toJSON path