Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use field in tokenization functions #119

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Ability to use field in tokenization functions #119

wants to merge 4 commits into from

Conversation

msotnikov
Copy link

Add the field value into pipeline function (token, i, tokens, field)

Inspired https://lunrjs.com/guides/customising.html#pipeline-functions

Expample usage:

  const skipField = function (fieldName, fn) {
    return function (token, i, tokens, field) {
      if (field === fieldName) {
        return token
      }

      return fn(token, i, tokens)
    }
  }
const selectiveStopWordfilter = skipField('fieldNameToSkip', elasticlunr.en.stopWordFilter)
  builder.pipeline.add(
    elasticlunr.trimmer,
    selectiveStopWordfilter,
)

@msotnikov msotnikov mentioned this pull request Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant