yeraydiazdiaz / lunr.py

A Python implementation of Lunr.js 🌖
http://lunr.readthedocs.io
MIT License
187 stars 16 forks source link

Support metadataWhitelist #120

Closed epicfaace closed 1 year ago

epicfaace commented 1 year ago

It would be good to support metadataWhitelist to store index positions, see https://github.com/olivernn/moonwalkers/blob/6d5a6e976921490033681617e92ea42e3a80eed0/build-index#L23-L29 and https://github.com/olivernn/lunr.js/issues/25

yeraydiazdiaz commented 1 year ago

Metadata whitelist is already supported, please see https://lunr.readthedocs.io/en/latest/customisation.html#token-meta-data

To have the position returned in the match data you simply need to append it to the whitelist:

builder.metadata_whitelist.append("position")

No need to register a function to the pipeline.