mirror of
https://github.com/typeable/bloodhound.git
synced 2024-10-26 16:38:51 +03:00
getting some instances rolling
This commit is contained in:
parent
5d5b954998
commit
182f89ccb2
@ -1,5 +1,4 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Database.Bloodhound.Client
|
||||
( createIndex
|
||||
@ -330,22 +329,45 @@ queryStringQuery query = emptyQueryStringQuery { query = query }
|
||||
type FieldName = Text
|
||||
|
||||
type Cache = Bool -- caching on/off
|
||||
data Filter = AndFilter [Filter] (Maybe Cache)
|
||||
| OrFilter [Filter] (Maybe Cache)
|
||||
| BoolFilter BoolMatch (Maybe Cache)
|
||||
data Filter = AndFilter [Filter] Cache
|
||||
| OrFilter [Filter] Cache
|
||||
| BoolFilter BoolMatch Cache
|
||||
| ExistsFilter FieldName -- always cached
|
||||
| GeoBoundingBoxFilter GeoBoundingBoxConstraint GeoFilterType (Maybe Cache)
|
||||
| GeoDistanceFilter GeoConstraint Distance (Maybe Cache)
|
||||
| GeoBoundingBoxFilter GeoBoundingBoxConstraint GeoFilterType Cache
|
||||
| GeoDistanceFilter GeoConstraint Distance Cache
|
||||
deriving (Show)
|
||||
|
||||
instance ToJSON Filter where
|
||||
toJSON (AndFilter filters cache) =
|
||||
object ["and" .= fmap toJSON filters
|
||||
, "_cache" .= cache]
|
||||
toJSON (OrFilter filters cache) =
|
||||
object ["or" .= fmap toJSON filters
|
||||
, "_cache" .= cache]
|
||||
toJSON (ExistsFilter fieldName) =
|
||||
object ["exists" .= object
|
||||
["field" .= fieldName]]
|
||||
toJSON (BoolFilter boolMatch cache) =
|
||||
object ["bool" .= toJSON boolMatch
|
||||
, "_cache" .= cache]
|
||||
|
||||
-- I dunno.
|
||||
data Term = Term { termField :: Text
|
||||
, termValue :: Text } deriving (Show)
|
||||
|
||||
instance ToJSON Term where
|
||||
toJSON (Term termField termValue) = object ["term" .= object
|
||||
[termField .= termValue]]
|
||||
|
||||
data BoolMatch = MustMatch Term
|
||||
| MustNotMatch Term
|
||||
| ShouldMatch [Term] deriving (Show)
|
||||
|
||||
instance ToJSON BoolMatch where
|
||||
toJSON (MustMatch term) = object ["must" .= toJSON term]
|
||||
toJSON (MustNotMatch term) = object ["must_not" .= toJSON term]
|
||||
toJSON (ShouldMatch terms) = object ["should" .= fmap toJSON terms]
|
||||
|
||||
-- "memory" or "indexed"
|
||||
data GeoFilterType = GeoFilterMemory | GeoFilterIndexed deriving (Show)
|
||||
|
||||
|
@ -16,6 +16,7 @@ build-type: Simple
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
default-extensions: OverloadedStrings
|
||||
exposed-modules: Database.Bloodhound.Client
|
||||
build-depends: base >=4.3 && <5,
|
||||
bytestring >= 0.10,
|
||||
|
Loading…
Reference in New Issue
Block a user