hunt-searchengine-0.3.0.1: A search and indexing engine.

Safe HaskellNone
LanguageHaskell98

Hunt.Index.Schema

Contents

Description

Schema for the ContextIndex.

Every context has a type (e.g. text, int, date, position) and additional schema information. This includes how keys are splitted and normalized when inserted and searched for.

Synopsis

Types

type Schema = Map Context ContextSchema Source

The global schema assigning schema information to each context.

data ContextSchema Source

The context schema information. Every context schema has a type and additional to adjust the behavior.

The regular expression splits the text into words which are then transformed by the given normalizations functions (e.g. to lower case).

Constructors

ContextSchema 

Fields

cxRegEx :: Maybe RegEx

Optional regex to override the default given by context type.

cxNormalizer :: [CNormalizer]

Normalizers to apply on keys.

cxWeight :: Weight

Context weight to boost results.

cxDefault :: Bool

Whether the context is searched in queries without context-specifier.

cxType :: ContextType

The type of the index (e.g. text, int, date, geo-position).

data ContextType Source

A general context type like text or int.

Constructors

CType 

Fields

ctName :: Text

Name used in the (JSON) API.

ctRegEx :: RegEx

Default regex to split words.

ctValidate :: CValidator

Validation function for keys.

ctIxImpl :: IndexImpl

The index implementation used for this type.

Instances

Show ContextType 
ToJSON ContextType 
FromJSON ContextType

Note: This is only partial (de-)serialization. The other components are environment-dependent and cannot be (de-)serialized. We serialize the name and identify the other compontens of the type later.

Binary ContextType 
Default ContextType 

type ContextTypes = [ContextType] Source

Set of context types.

data CValidator Source

Validation function for single words.

Constructors

CValidator 

Fields

validate :: Word -> Bool
 

data CNormalizer Source

Normalizer for words/keys of an index.

Constructors

CNormalizer 

Fields

cnName :: Text

Name used in (JSON) API.

normalize :: Text -> Text

Normalization function.

normalize' :: [CNormalizer] -> Word -> Word Source

Apply the normalizers to a word.

Default Context Types

ctText :: ContextType Source

Text context type.

ctTextSimple :: ContextType Source

Special text context type smaller index but not phrase queries possible (due to not storing the words positions)

ctInt :: ContextType Source

Int context type.

ctDate :: ContextType Source

Date context type.

ctPosition :: ContextType Source

Geographic position context type.

Default Normalizers

cnUpperCase :: CNormalizer Source

Uppercase normalizer "UpperCase".

cnLowerCase :: CNormalizer Source

Lowercase normalizer "LowerCase".

cnZeroFill :: CNormalizer Source

Int normalizer "ZeroFill" to preserve int ordering on strings.