@@ -45,6 +45,8 @@ module Database.Bloodhound.Client
45 , LessThanEq(..)
45 , LessThanEq(..)
46 , GreaterThan(..)
46 , GreaterThan(..)
47 , GreaterThanEq(..)
47 , GreaterThanEq(..)
@@ -370,8 +372,10 @@ queryStringQuery query = emptyQueryStringQuery { query = query }
371type FieldName = Text
373type FieldName = Text
373−type Cache = Bool -- caching on/off
375+type Cache = Bool -- caching on/off
376+type CacheName = Text
374−defaultCache = False
378+defaultCache = False
376type Existence = Bool
380type Existence = Bool
377type NullValue = Bool
381type NullValue = Bool
@@ -392,6 +396,7 @@ data Filter = AndFilter [Filter] Cache
392 | MissingFilter FieldName Existence NullValue
396 | MissingFilter FieldName Existence NullValue
393 | PrefixFilter FieldName PrefixValue Cache
397 | PrefixFilter FieldName PrefixValue Cache
394 | RangeFilter FieldName (Either HalfRange Range) RangeExecution Cache
398 | RangeFilter FieldName (Either HalfRange Range) RangeExecution Cache
399+ | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
395 deriving (Eq, Show)
400 deriving (Eq, Show)
397class Monoid a => Seminearring a where
402class Monoid a => Seminearring a where
@@ -497,6 +502,15 @@ instance ToJSON Filter where
498 (lessKey, lessVal, greaterKey, greaterVal) = rangeToKV range
503 (lessKey, lessVal, greaterKey, greaterVal) = rangeToKV range
505+ toJSON (RegexpFilter fieldName (Regexp regexText) flags cacheName cache cacheKey) =
507+ object [fieldName .=
508+ object ["value" .= regexText
509+ , "flags" .= toJSON flags]
510+ , "_name" .= cacheName
512+ , "_cache_key" .= cacheKey]]
500instance ToJSON GeoPoint where
514instance ToJSON GeoPoint where
501 toJSON (GeoPoint geoField latLon) =
515 toJSON (GeoPoint geoField latLon) =
502 object [geoField .= toJSON latLon]
516 object [geoField .= toJSON latLon]
@@ -586,6 +600,34 @@ instance ToJSON RangeExecution where
586 toJSON RangeExecutionIndex = "index"
600 toJSON RangeExecutionIndex = "index"
587 toJSON RangeExecutionFielddata = "fielddata"
601 toJSON RangeExecutionFielddata = "fielddata"
603+newtype Regexp = Regexp Text deriving (Eq, Show)
604+data RegexpFlags = RegexpAll
612+ | IntervalIntersection
614+ | IntersectionAnyString deriving (Eq, Show)
616+instance ToJSON RegexpFlags where
617+ toJSON RegexpAll = String "ALL"
618+ toJSON Complement = String "COMPLEMENT"
619+ toJSON Interval = String "INTERVAL"
620+ toJSON Intersection = String "INTERSECTION"
621+ toJSON AnyString = String "ANYSTRING"
622+ toJSON CompInterval = String "COMPLEMENT|INTERVAL"
623+ toJSON CompIntersection = String "COMPLEMENT|INTERSECTION"
624+ toJSON CompAnyString = String "COMPLEMENT|ANYSTRING"
625+ toJSON IntervalIntersection = String "INTERVAL|INTERSECTION"
626+ toJSON IntervalAnyString = String "INTERVAL|ANYSTRING"
627+ toJSON IntersectionAnyString = String "INTERSECTION|ANYSTRING"
629+-- phew. Coulda used Agda style case breaking there but, you know, whatever. :)
589data Term = Term { termField :: Text
631data Term = Term { termField :: Text
590 , termValue :: Text } deriving (Eq, Show)
632 , termValue :: Text } deriving (Eq, Show)