[go: up one dir, main page]

Remove position from the index to reduce the index size

Lunr can store metadata regarding the position of the term matches in a document: https://lunrjs.com/guides/core_concepts.html#search-results

Storing metadata about the term and field is opt-in, this is to keep the size of the search index as small as possible. To enable positions of term matches the ‘positions’ metadata must be white-listed when building the index:

This feature is currently enabled but as mentioned in the documentation it has a significant impact on the size of the search index. Disabling this feature can cut the size of the search index in half!

The downside is that we are using the position metadata when building the search result items to highlight term matches:

https://gitlab.com/antora/antora-lunr-extension/-/blob/4231c5c0d041199452c1240237cbc3aa42a98964/supplemental_ui/js/search-ui.js#L86

If we disable this feature then we will need to infer the position of the search term(s) in the title or text content. I think it's a reasonable tradeoff as it should be relatively fast to find term matches.