olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.96k stars 548 forks source link

Unexpected behavior: numeric type refs get converted to strings once indexed. #326

Closed sherbondy closed 6 years ago

sherbondy commented 6 years ago

Hi there!

Love the library, but ran into unexpected behavior recently when updating from the ancient 0.6 release to the new-and-shiny 2.1.5 release.

Notably, I was formerly passing in an id ref with a numeric value, and the older lunr.js codebase seemingly left my ref types alone.

Now, refs get coerced into strings once more!

Is this the desired / expected behavior of the library? Is there a new technical/performance reason behind this change related to the introduction of the immutable index?

The Changelog indicates this is a regression from 0.6 where the problem was originally resolved: #117

Simple repro notebook on RunKit just for fun: https://runkit.com/sherbondy/lunr-js-2-1-5-converts-ref-values-to-strings-unexpectedly

Thanks for making lunr!

olivernn commented 6 years ago

I remember the issue you are talking about. I honestly can't remember the reasons why this change in 2.x of Lunr, but looking at the docs it seems I did call it out specifically!

I'm not against 'fixing' this regression and would welcome pull requests with such changes ;)

I'll take a look into it myself also, but its not super high on my list of things to work on in Lunr.

olivernn commented 6 years ago

Going to close this now as this is documented behaviour (though it has changed during the major version bump from 0/1 to 2).

As mentioned before, I am open to pull requests that support numeric refs, but I don't see myself getting to this anytime soon.