You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lunr allows you to skip steps in the pipeline for specific fields, as detailed in the customization document. Unfortunately this functionality is not very useful, because these skips are only applied during indexing and not during search. Here is an example:
fromlunrimportlunr, get_default_builder, stop_word_filter, stemmerbuilder=get_default_builder()
builder.pipeline.skip(stop_word_filter.stop_word_filter, ["title"])
# Add the stop word filter to the pipeline (see #151)builder.search_pipeline.before(stemmer.stemmer, stop_word_filter.stop_word_filter)
builder.search_pipeline.skip(stop_word_filter.stop_word_filter, ["title"])
index=lunr(
ref="id",
fields=["title", "body"],
documents=[
# The title is entirely stopwords, but will index them anyway
{"id": "1", "title": "To be or not to be?", "body": "That is the question!"}
],
builder=builder,
)
print(index.search("title:to")) # Should print something, but doesn'tprint(index.search("body:the")) # Should print []print(index.search("to")) # Should print something, but doesn't
Because skipping fields isn't a super common thing to do, but also because of #151 (the stop word filter is never applied to the query anyway) this isn't always noticeable in normal use, which is probably why it never got fixed in lunr.js.
Lunr allows you to skip steps in the pipeline for specific fields, as detailed in the customization document. Unfortunately this functionality is not very useful, because these skips are only applied during indexing and not during search. Here is an example:
Because skipping fields isn't a super common thing to do, but also because of #151 (the stop word filter is never applied to the query anyway) this isn't always noticeable in normal use, which is probably why it never got fixed in lunr.js.
As with #151 this can't be fixed without breaking bug-compatibility with lunr.js (see https://github.com/olivernn/lunr.js/blob/master/lib/index.js#L173), but I wanted to document the workaround.
The text was updated successfully, but these errors were encountered: