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

"Out of order word insertion" in lunr.js due to differences in string comparison between Python and JavaScript? #144

Open
abdnh opened this issue Dec 14, 2023 · 2 comments

Comments

@abdnh
Copy link

abdnh commented Dec 14, 2023

I'm using lunr.py to create a search index for use with lunr.js, and I hit an issue that I believe is due to differences in how Python and JavaScript compare strings.

One example to reproduce the issue:

"🔥" < "\uf0ae" 

This evaluates to false in Python but true in JavaScript.

What's the best way to handle this?

@yeraydiazdiaz
Copy link
Owner

Can you provide a more complete example the interaction between the indices from lunr.py and lunr.js?

@abdnh
Copy link
Author

abdnh commented Mar 24, 2024

Here's an example to reproduce the error.

  1. Create a search index using lunr.py:
import json

from lunr import lunr

documents = [
    {
        "id": "a",
        "body": "🔥",
    },
    {
        "id": "b",
        "body": "\uf0ae",
    },
]

idx = lunr(ref="id", fields=("body",), documents=documents)
with open("index.json", "w", encoding="utf-8") as file:
    json.dump(idx.serialize(), file)
  1. Load it into lunr.js (Example in node.js):
const lunr = require("lunr");

async function loadIndex() {
    const serializedIndex = require("./index.json");
    lunr.Index.load(serializedIndex);
}

loadIndex();

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

No branches or pull requests

2 participants