HsHyperEstraier-0.4: HyperEstraier binding for Haskell

Text.HyperEstraier.Condition

Contents

Description

An interface to functions to manipulate search conditions.

Synopsis

Types

data Condition

Condition is an opaque object representing a search condition.

data CondOption

CondOption is an option to the search condition.

Constructors

Speed SearchSpeed

Choose a SearchSpeed.

OmitTFIDF

Omit calculating TF-IDF weight.

Syntax SyntaxType

Choose a SyntaxType.

data SearchSpeed

SearchSpeed is an option to the search condition.

Constructors

Slow

Search for all N-gram keys.

Normal

Search for N-gram keys alternately.

Fast

Search for N-gram keys by skipping 2/3 of them.

EvenFaster

Search for N-gram keys by skipping 3/4 of them.

data SyntaxType

SyntaxType is an option to the search condition.

Constructors

Simplified

Interpret the condition phrase as the simplified syntax. See the user's guide of the HyperEstraier for explanation about the simplified syntax.

Rough

Interpret the condition phrase as the rough syntax. See the user's guide for details.

Union

Interpret the condition phrase as the union syntax. See the user's guide for details.

Intersection

Interpret the condition phrase as the intersection syntax. See the user's guide for details.

data Eclipse

Eclipse represents how to hide documents from the search result by their similarity.

Constructors

Threshold Double

Threshold to cause eclipse to documents. Threshold x must satisfy 0.0 <= x <= 1.0.

ThresholdWithURL Double

This is similar to Threshold but this specifies that the document URI is also used to calculate the similarity.

SameServer

Cause eclipse to the documents on the same server.

SameDirectory

Cause eclipse to the documents in the same directory.

SameFile

Cause eclipse to the documents whose file name is the same.

Instances

Manipulating conditions

newCondition :: IO Condition

newCondition creates an empty search condition.

setPhrase :: Condition -> Text -> IO ()

setPhrase cond phrase stores a condition phrase into cond. The syntax of the phrase is assumed to be the normal syntax, unless you specify a SyntaxType explicitly with setOptions.

addAttrCond :: Condition -> Text -> IO ()

addAttrCond cond expr appends an attribute search condition to cond. See the user's guide for explanation about the attribute search condition.

setOrder :: Condition -> Text -> IO ()

setOrder cond expr stores an ordering expression into cond. See the user's guide for explanation about the ordering expression. By default, the result is sorted in descending order of score.

setMax :: Condition -> Int -> IO ()

setMax cond n specifies the maximum number of results. By default, the number of results is unlimited.

setSkip :: Condition -> Int -> IO ()

setSkip cond n specifies how many documents should be skipped from the beginning of result.

setOptions :: Condition -> [CondOption] -> IO ()

setOptions cond opts specifies options to the search condition.

setAuxiliary :: Condition -> Int -> IO ()

setAuxiliary cond min specifies how many documents should be in the result to avoid using the auxiliary index to pad the result.

setEclipse :: Condition -> Eclipse -> IO ()

setEclipse cond ecl specifies how to hide documents from the search result by their similarity.

setDistinct :: Condition -> Text -> IO ()

setDistinct cond attr specifies an attribute which must be unique to the search result.

setMetaSearchMask :: Condition -> [Int] -> IO ()

setMetaSearchMask cond xs specifies that, in Text.HyperEstraier.Database.metaSearch, some databases must be excluded from the search result. e.g.

 main = withDatabase "db1" (Reader []) $ \ db1 
        withDatabase "db2" (Reader []) $ \ db2 
        withDatabase "db3" (Reader []) $ \ db3 
        do cond <- newCondition
           setPhrase cond "hello AND world"
           setMetaSearchMask cond [0, 2] -- zero-origin

           -- In this case, "db1" and "db3" are excluded from the meta search.
           result <- metaSearch [db1, db2, db3] 
           print result