git.iko.soy/typeable/bloodhound
on master help sign in
uhhhh
bfaeb92Chris Allen
Database/Bloodhound/Client.hs+114−1
@@ -148,7 +148,7 @@ dispatch url method body = do
148type IndexName = String
148type IndexName = String
149
149
150joinPath :: [String] -> String
150joinPath :: [String] -> String
151−joinPath path = intercalate "/" path
151+joinPath = intercalate "/"
152
152
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]
272
272
273+-- data Analyzer = AStandardAnalyzer StandardAnalyzer
274+-- | SimpleAnalyzer -- just "simple"
275+-- | WhitespaceAnalyzer
276+-- | StopAnalyzer
277+-- | KeywordAnalyzer
278+-- | PatternAnalyzer
279+-- | LanguageAnalyzer
280+-- | SnowballAnalyzer
281+-- | CustomAnalyzer
282+
283+-- data StandardAnalyzer =
284+-- StandardAnalyzer
285+-- { stopwords :: Maybe [Text] -- default []
286+-- , max_token_length :: Maybe Int -- default 255
287+-- }
288+
289+-- DefaultField -> "default_field": ""
290+-- Fields -> "fields": []
291+
292+type QueryString = Text
293+-- status:active
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
298+
299+data BooleanOperator = AND | OR deriving (Show)
300+
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)
304+
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
324+ } deriving (Show)
325+
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 }
328+
329+-- ugh
330+type FieldName = Text
331+
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)
339+ deriving (Show)
340+
341+-- I dunno.
342+data Term = Term { termField :: Text
343+ , termValue :: Text } deriving (Show)
344+
345+data BoolMatch = MustMatch Term
346+ | MustNotMatch Term
347+ | ShouldMatch [Term] deriving (Show)
348+
349+-- "memory" or "indexed"
350+data GeoFilterType = GeoFilterMemory | GeoFilterIndexed deriving (Show)
351+
352+data LatLon = LatLon { lat :: Double, lon :: Double } deriving (Show)
353+data GeoBoundingBox = { topLeft :: LatLon
354+ , bottomRight :: LatLon } deriving (Show)
355+
356+data GeoBoundingBoxConstraint =
357+ GeoBoundingBoxConstraint { geoField :: Text
358+ , constraintBox :: GeoBoundingBox
359+ } deriving (Show)
360+
361+data DistanceUnits = Miles
362+ | Yards
363+ | Feet
364+ | Inches
365+ | Kilometers
366+ | Meters
367+ | Centimeters
368+ | Millimeters
369+ | NauticalMiles deriving (Show)
370+
371+data DistanceType = Arc | SloppyArc | Plane deriving (Show)
372+
373+-- geo_point?
374+data OptimizeBbox = GeoFilterType | NoOptimizeBbox deriving (Show)
375+
376+data Distance = { coefficient :: Double
377+ , unit :: DistanceUnits } deriving (Show)
378+-- This is turning into a fractal of horror
379+-- data Fuzziness = FDateFuzziness DateFuzziness |
380+
381+-- data Query = Query { query :: () } deriving (Show)
382+-- search :: Server -> IndexName -> Maybe MappingName
383+-- -> Query -> IO Reply
384+-- search = fuck
385+
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