@@ -148,7 +148,7 @@ dispatch url method body = do
148type IndexName = String
148type IndexName = String
150joinPath :: [String] -> String
150joinPath :: [String] -> String
151−joinPath path = intercalate "/" path
151+joinPath = intercalate "/"
153getStatus :: Server -> IO (Maybe (Status Version))
153getStatus :: Server -> IO (Maybe (Status Version))
154getStatus (Server server) = do
154getStatus (Server server) = do
@@ -270,6 +270,119 @@ documentExists (Server server) indexName mappingName docId = do
270 return exists where
270 return exists where
271 url = joinPath [server, indexName, mappingName, docId]
271 url = joinPath [server, indexName, mappingName, docId]
273+-- data Analyzer = AStandardAnalyzer StandardAnalyzer
274+-- | SimpleAnalyzer -- just "simple"
275+-- | WhitespaceAnalyzer
279+-- | LanguageAnalyzer
280+-- | SnowballAnalyzer
283+-- data StandardAnalyzer =
285+-- { stopwords :: Maybe [Text] -- default []
286+-- , max_token_length :: Maybe Int -- default 255
289+-- DefaultField -> "default_field": ""
290+-- Fields -> "fields": []
292+type QueryString = Text
294+-- author:"John Smith"
295+-- for book.title and book.date containing quick OR brown, book.\*:(quick brown)
296+-- field title has no value or doesn't exist, _missing_:title
297+-- field title has any non-null value, _exists:title
299+data BooleanOperator = AND | OR deriving (Show)
301+type DisMax = Bool -- "use_dis_max"
302+newtype TieBreaker = TieBreaker Int deriving (Show)
303+data QueryField = DefaultField Text | Fields [Text] DisMax TieBreaker deriving (Show)
305+data QueryStringQuery =
306+ QueryStringQuery { query :: QueryString
307+ , field :: Maybe QueryField -- default _all
308+ , defaultOperator :: Maybe BooleanOperator -- default OR
309+ , analyzer :: Maybe Text -- analyzer name
310+ , allowLeadingWildcard :: Maybe Bool -- default true
311+ , lowercaseExpandedTerms :: Maybe Bool -- default true
312+ , enablePositionIncrements :: Maybe Bool -- default true
313+ , fuzzyMaxExpansions :: Maybe Int -- default 50
314+ , fuzziness :: Maybe Text -- Fuzziness -- default AUTO, add type later
315+ , fuzzyPrefixLength :: Maybe Int -- default 0
316+ , phraseSlop :: Maybe Int -- default 0, 0 means exact phrase matches
317+ , boost :: Maybe Double -- default 1.0
318+ , analyzeWildcard :: Maybe Bool -- default false, true forces wildcard analysis
319+ , autoGeneratePhraseQueries :: Maybe Bool -- default false
320+ , minimumShouldMatch :: Maybe Text -- # "should" clauses in the boolean query should match
321+ -- Text to handle weird % and other cases. Needs type
322+ , lenient :: Maybe Bool -- default false, true shuts off format based failures
323+ , locale :: Maybe Text -- default ROOT, locale used for string conversions
326+emptyQueryStringQuery = QueryStringQuery "" Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
327+queryStringQuery query = emptyQueryStringQuery { query = query }
330+type FieldName = Text
332+type Cache = Bool -- caching on/off
333+data Filter = AndFilter [Filter] (Maybe Cache)
334+ | OrFilter [Filter] (Maybe Cache)
335+ | BoolFilter BoolMatch (Maybe Cache)
336+ | ExistsFilter FieldName -- always cached
337+ | GeoBoundingBoxFilter FieldName GeoBoundingBoxConstraint GeoFilterType (Maybe Cache)
338+ | GeoDistanceFilter FieldName LatLon Distance (Maybe Cache)
342+data Term = Term { termField :: Text
343+ , termValue :: Text } deriving (Show)
345+data BoolMatch = MustMatch Term
347+ | ShouldMatch [Term] deriving (Show)
349+-- "memory" or "indexed"
350+data GeoFilterType = GeoFilterMemory | GeoFilterIndexed deriving (Show)
352+data LatLon = LatLon { lat :: Double, lon :: Double } deriving (Show)
353+data GeoBoundingBox = { topLeft :: LatLon
354+ , bottomRight :: LatLon } deriving (Show)
356+data GeoBoundingBoxConstraint =
357+ GeoBoundingBoxConstraint { geoField :: Text
358+ , constraintBox :: GeoBoundingBox
361+data DistanceUnits = Miles
369+ | NauticalMiles deriving (Show)
371+data DistanceType = Arc | SloppyArc | Plane deriving (Show)
374+data OptimizeBbox = GeoFilterType | NoOptimizeBbox deriving (Show)
376+data Distance = { coefficient :: Double
377+ , unit :: DistanceUnits } deriving (Show)
378+-- This is turning into a fractal of horror
379+-- data Fuzziness = FDateFuzziness DateFuzziness |
381+-- data Query = Query { query :: () } deriving (Show)
382+-- search :: Server -> IndexName -> Maybe MappingName
383+-- -> Query -> IO Reply
273-- getStatus :: String -> IO (Maybe (Status Version))
386-- getStatus :: String -> IO (Maybe (Status Version))
274-- getStatus server = do
387-- getStatus server = do
275-- request <- parseUrl $ server ++ rootPath
388-- request <- parseUrl $ server ++ rootPath