orus-io / elm-simple-text-index / SimpleTextIndex

Init


type Index doc

An Index holds data to quickly find doc document given doc substring of its indexed fields

new : Config doc -> Index doc

Creates doc new empty Index

Configure


type Config doc

A Config is required to add/search in an Index

config : { ref : doc -> String, fields : List (doc -> String), normalize : String -> String } -> Config doc

Create doc config

A typical config is:

{ ref = .id
, fields = [ .name, .description ]
, normalize = Sring.toLower >> String.Normalize.removeDiacritics
}

setMaxResultSize : Basics.Int -> Config a -> Config a

Set the maximum number of results to return on a search

The default value is 1000

This value is indicative only and result may be bigger

setConfig : Config doc -> Index doc -> Index doc

Update the index configuration

Insert data

add : doc -> Index doc -> Index doc

Add a document to an index

Search

search : String -> Index doc -> List doc

Search a document in the index