jxxcarlson/elm-text-search/1.0.1

NOTE: the latest version is 2.0.0

TextSearch.Search

Basic usage

Let

match =
    Search.withQueryString
        identity
        Search.NotCaseSensitive
        "foo -bar | baz"

Run match on the list

    [ "foo yada", "foo bar", "hehe, baza baza!" ]

It will return

    [ ""foo yada", "hehe, baza baza!" ]

The query string foo -bar | baz is of the form P | Q. It will match anything that matches P or Q. The term P is form word1 -word2 It will match anything that contains word1 but not word2. Similarly word1 word2 matches anything that contains word1 and word2.

Non-string data

Suppose that you want to query data of type List Datum. You can do this if you have function like digest : Datum -> String. For example, if

```text
type alias Datum =
  {   title: String
    , tags : List String
    , ... other stuff ...
   }
```


Then `digest datum = String.join " " title::tags`
does the job — you can search using


```text
Search.withQueryString
   digest
   Search.NotCaseSensitive
   "abc -xyz | pqr"
```
matchWithQueryString : (datum -> String) -> Config -> String -> datum -> Bool
matchWithQueryTerm : (datum -> String) -> Config -> QueryTerm -> datum -> Bool
withQueryString : (datum -> String) -> Config -> String -> List datum -> List datum
type Config
= CaseSensitive
| NotCaseSensitive