heywhy / ex_elasticlunr

Elasticlunr is a small, full-text search library for use in the Elixir environment. It indexes JSON documents and provides a friendly search interface to retrieve documents.
https://hexdocs.pm/elasticlunr
MIT License
189 stars 9 forks source link

Wildcard search? #20

Open zachdaniel opened 2 years ago

zachdaniel commented 2 years ago

I'm not familiar with elasticsearch's searching, but I can't seem to find a way to do wildcard searching with ex_elasticlunr. I'm powering a simple type-ahead documentation search field.

heywhy commented 2 years ago

Hello @zachdaniel, to achieve this you can use the below sample:

Index.search(index, %{
  "query" => %{
    "match" => %{
      "field" => %{
        "query" => "user's query",
        "expand" => true
      }
    }
  }
})

Note that improvements are ongoing behind the scene and I'm working to produce a good library that works well. So, if you have any feedback do not hesitate to let me know. And you can refer to this post or the livebook document included in the repository to learn more about the available options for each query type