question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to change lunr tokenizer

See original GitHub issue

In order to make search more powerful, adding the ability to change the lunr.tokenizer.seperator would be nice.

https://github.com/olivernn/lunr.js/blob/master/lib/tokenizer.js#L69-L76

Out of the box, if you have the string: this.test

The query test will return empty, but this.t will return this.test.

By changing the regex used for tokenization, you could solve problems like this

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
saminzadehcommented, Sep 7, 2018

I am wondering because if we implement this feature for devs then it could be as separator / regex option or as one of list of predefined analyzers (i.e. like in https://www.elastic.co/guide/en/elasticsearch/reference/2.3/analyzer.html).

Hmm, yes that could be nice. But I agree, would probably want to iron that out a bit more before it is introduced into the API interface.

Second seems nice but first (your suggestion) the simplest to start with and very flexible

Yes I think this could be the best starting point. Just having access to the lunr object via itemsjs would be the most flexible for advanced users and will ensure the correct dependency

Something like this:

import lunr from 'itemjs/lunr';

lunr.tokenizer.separator = /[\s\-[\]:]+/g;

or

import ItemsJS from 'itemjs';
const index = ItemsJS(data, config);
index.lunr.tokenizer.separator = /[\s\-[\]:]+/g;

index.search({...})
0reactions
cigolplcommented, Apr 9, 2021

@saminzadeh I’ve introduced simple full text integration with all external search engines in the latest version. You can see here -> https://github.com/itemsapi/itemsjs/blob/master/docs/lunr2-integration.md or in Readme

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples how to customize lunr #230 - GitHub
Hi, Maybe it's dumb question but I couldn't realize how to add custom tokenizer to lunr, is it possible? Where can I find...
Read more >
JSDoc: Source: tokenizer.js - Lunr.js
Uses `lunr.tokenizer.separator` to split strings, change; * the value of this property to change how strings are split into tokens.
Read more >
lunr.js - RDoc Documentation
Uses `lunr.tokenizer.separator` to split strings, change * the value of this property to change how strings are split into tokens. * * This...
Read more >
lunr.py
Lunr is a simple full text search solution for situations where deploying a full scale solution like Elasticsearch isn't.
Read more >
lunr-mutable-indexes - npm
Mutable indexes work by having a handle to their original builder - this inflates the index size a bit. · Changing a builder's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found