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.
These changes allow one to index documents with nested attributes and search using dot notation. Example:
# user structure coming from a data source
%{
"id" => 1,
"name" => "peter simons",
"address" => %{
"line1" => "some random street",
"city" => "booming city",
"country" => "somewhere on earth"
}
}
# the user object is flattened to this structure before it is indexed
%{
"id" => 1,
"name" => "peter simons",
"address.line1" => "some random street",
"address.city" => "booming city",
"address.country" => "somewhere on earth",
}
Considering the transformation that happened before indexing the document, you can now query the index for certain
criteria on the nested attributes.
It's important to note that you don't need to specify the nested fields at the point of creating the index as long as the top-level attribute, address, is specified. The library handles this internal mapping so you don't have to worry.
Related Issues
4
TODO
[x] Write tests to support these changes
[x] GitHub Actions are all passing
What to test:
[x] Index documents with nested attributes
[x] Make sure you can query the nested attributes using the dot annotation
Overview
These changes allow one to index documents with nested attributes and search using dot notation. Example:
Considering the transformation that happened before indexing the document, you can now query the index for certain criteria on the nested attributes.
It's important to note that you don't need to specify the nested fields at the point of creating the index as long as the top-level attribute,
address
, is specified. The library handles this internal mapping so you don't have to worry.Related Issues
4
TODO
What to test: