lunr.js | A bit like Solr , but much smaller and not as bright | Search Engine library

 by   olivernn JavaScript Version: v2.3.9 License: MIT

kandi X-RAY | lunr.js Summary

kandi X-RAY | lunr.js Summary

lunr.js is a JavaScript library typically used in Database, Search Engine applications. lunr.js has no vulnerabilities, it has a Permissive License and it has medium support. However lunr.js has 3 bugs. You can install using 'npm i lunr-zh-cn' or download it from GitHub, npm.

Lunr.js is a small, full-text search library for use in the browser. It indexes JSON documents and provides a simple search interface for retrieving documents that best match text queries.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              lunr.js has a medium active ecosystem.
              It has 8540 star(s) with 585 fork(s). There are 129 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 92 open issues and 294 have been closed. On average issues are closed in 127 days. There are 28 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of lunr.js is v2.3.9

            kandi-Quality Quality

              lunr.js has 3 bugs (0 blocker, 0 critical, 3 major, 0 minor) and 0 code smells.

            kandi-Security Security

              lunr.js has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              lunr.js code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              lunr.js is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              lunr.js releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions, examples and code snippets are available.
              lunr.js saves you 283 person hours of effort in developing the same functionality from scratch.
              It has 684 lines of code, 0 functions and 56 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lunr.js
            Get all kandi verified functions for this library.

            lunr.js Key Features

            No Key Features are available at this moment for lunr.js.

            lunr.js Examples and Code Snippets

            No Code Snippets are available at this moment for lunr.js.

            Community Discussions

            QUESTION

            How to implement fulltext search for offline website
            Asked 2020-Dec-26 at 14:13

            I need a client-side fulltext search for big offline website. The site is opened by browser. I've made a research and found some solutions - fullproof, fuse.js, flexsearch.js, elasticlunr.js. I searched for js libs, because as i inderstand, it's the single solution (please correct me if i'm wrong).

            Also i can't clearly understand some moments:

            1. As i know, browsers due to security policy block all scripts' execution from javascripts files. I couldn't run examples from fullproof git because of this problem, but i managed to run flexsearch example, because script execution was included in html code with tag. Can i implement some search system for my local website because i don't use any local server for hosting (like xampp)?
            2. From documentation for different js libs i undestand, that all they use for indexing either variable with list of key words or json file. Maybe i have a luck of information, but how i can use search system to find words/expressions from the whole website (it has a main page and a lot of included pages with information)? Do i have to create some sort of database or some json file?

            I'll be very grateful for your answers, explanations, solutions or maybe examples about this problem, thank you!

            ...

            ANSWER

            Answered 2020-Dec-26 at 14:13

            Firts of all, browsers doesn't block js scripts execution. Secondly, i managed to find two ways to solve my problem - keywords search and fulltext search: 1) I created a database with keywords (json file) and used flexsearch library to search in this database. Example of usage u can find on their website, either an example of json file. 2) This time i created a database (json file), in which one recording is a text content of a website. Then again i used flexsearch to find a word in this database. After appropriate site was found, it opened up and the searched word was highlighted (u can find such js libraries in net). All the solutions don't require any internet connection and can be used for offline websites.

            Source https://stackoverflow.com/questions/63281063

            QUESTION

            After clicking a link and loading a new page how can I then run a function?
            Asked 2020-Aug-16 at 21:11

            I'm making a Hybrid app using cordova and currently when users use the search function a list of clickable search results return with the users search query highlighted in each result. The problem is when a user clicks on a result and it brings them to the exact location of the search query in the said book, I can not figure out how to run my highlight function to hightlight search query on the newly loaded page? New to Javascript here and I Hope I am clear on what I am trying to say. Here is a screen recording of the problem https://osaintilien55-gmail.tinytake.com/tt/NDU0MzA5OF8xNDQwMDE2Ng. I am using Lunr.js for search functionality and Mark.js for highlighting.

            Here is the search function in my code

            ...

            ANSWER

            Answered 2020-Aug-16 at 21:11

            You could use query strings. For example, the parameters of a function are stored in a query string called params.

            You could read the query string. Then use JSON.parse() on the query string. Then run the function with the parsed array using the ES6 spread operator (...).

            Example:

            Source https://stackoverflow.com/questions/63441331

            QUESTION

            How to open a new page with search results in Jekyll using w/ Lunr.js?
            Asked 2020-Apr-22 at 04:57

            I'm having a bit of trouble trying to display the search result in a new page titled results.html using this guide here.

            It seems as though its setup to display results on the page where the search is being made which isn't what I'm looking for.

            What I'm trying to do is have a search box in index.html, which opens a new page after pressing a button that contains search results.

            Currently any search that is made on any page, just shows the results there.

            _includes/search-lunr.html

            ...

            ANSWER

            Answered 2020-Apr-22 at 04:57

            If you want the search results only on a separate page, you'll want the search form to have an action that points to it. The term will be passed to that page, which can then process it and display the search results.

            This template demonstrates this exact flow:

            It's a pretty good solution since your site viewers only have to load and run that code if they perform a search, which can be a substantial saving with a reasonably sized index.

            To replicate it roughly with your code above:

            1. Remove {% include search-lunr.html %} from your index.html.

            2. Have this on index.html:

            Source https://stackoverflow.com/questions/61314218

            QUESTION

            Regex to replace leading plus characters in query params (++, +- and +)?
            Asked 2020-Mar-16 at 17:24

            I am using lunr.js.

            This Javascript code below

            • gets the query parameters from the first search
            • replaces the binding + characters with spaces
            • stores the modified query in the search field for the next search
            • Then it finally searches using the modified query
            ...

            ANSWER

            Answered 2020-Mar-16 at 17:24

            QUESTION

            How to search a nested dictionary and not care about top level key
            Asked 2020-Feb-18 at 23:56

            So I am using lunr.js in my Jekyll application to implement a search feature and the results return correctly. The aim is to then display the list of results in the browser.

            Here I get the results, then pass them to a func which handles the DOM manipulation.

            ...

            ANSWER

            Answered 2020-Feb-18 at 23:05

            You can use Object.values() to access only the values of the object. Example:

            Source https://stackoverflow.com/questions/60290646

            QUESTION

            Can't get object out of array for display
            Asked 2019-Jul-23 at 12:35

            I'm trying to build a simple search interface for a dataset that I have created.

            I have followed the Lunr guides to create an index. I put an input box on my webpage that gets the search value typed by the user, then runs that value against the index.

            When I run console.log(results[0]) - I happily get the right result in my console:

            The problem comes when I try to get "legal and legislation compliance" to show up on my webpage. Two things happen:

            When I try to output console.log(results[0].ref) to the console, the program freezes and I can't type anymore.

            When I try to output document.getElementById("demo").innerHTML= results[0] to the webpage I get [object object] - which is surprising because the console line gives the actual data associated to the object.

            ...

            ANSWER

            Answered 2019-Jul-23 at 12:35

            You should use a value for innerHTML. Here results[0] is a object. So this should be document.getElementById("demo").innerHTML = results[0].ref

            Source https://stackoverflow.com/questions/57154322

            QUESTION

            ENOTFOUND Package mkdirp not found or ENOTFOUND Package minimist not found
            Asked 2017-Nov-29 at 14:58

            Background:

            My web project with following bower.json was successfully compiled 4 months back with no modifications till date using gitlab ci pipeline (there is no change in code since then). Today, when i re-executed pipeline, bower started throwing ENOTFOUND errors as mentioned later in this question.

            Errors in various run are ENOTFOUND Package mkdirp not found or ENOTFOUND Package minimist not found. How to rectify or trace source of this error maybe in terms of 3rd party package problems considering no change in bower.json and source code and also log file does not mention from which 3rd party mkdirp or minimist is demanded. As such, This is wired as Why would bower remove pre-existing packages from repository.

            bower.json snippet

            ...

            ANSWER

            Answered 2017-Nov-29 at 14:58

            Gave up with random ENOTFOUND Package * not found errors for very long and display of package names even am not aware of or searchable in google like package ENOTFOUND Package which not found.

            Thereafter came across this article which referred to Yarn as better replacement to NPM and Bower. Thus i've used stackoverflow article to migrate my project from npm/bower to yarn and errors are gone.

            Code used for same after installation of yarn is: (it needs previous copy of bower_components folder to exist with node_modules)

            Source https://stackoverflow.com/questions/47188374

            QUESTION

            How to search for closest tag set match in JavaScript?
            Asked 2017-Oct-12 at 20:42

            I have a set of documents, each annotated with a set of tags, which may contain spaces. The user supplies a set of possibly misspelled tags and I wants to find the documents with the highest number of matching tags (optionally weighted).

            There are several thousand documents and tags but at most 100 tags per document.

            I am looking on a lightweight and performant solution where the search should be fully on the client side using JavaScript but some preprocessing of the index with node.js is possible.

            My idea is to create an inverse index of tags to documents using a multiset, and a fuzzy index that that finds the correct spelling of a misspelled tag, which are created in a preprocessing step in node.js and serialized as JSON files. In the search step, I want to consult for each item of the query set first the fuzzy index to get the most likely correct tag, and, if one exists to consult the inverse index and add the result set to a bag (numbered set). After doing this for all input tags, the contents of the bag, sorted in descending order, should provide the best matching documents.

            My Questions

            1. This seems like a common problem, is there already an implementation for it that I can reuse? I looked at lunr.js and fuse.js but they seem to have a different focus.
              1. Is this a sensible approach to the problem? Do you see any obvious improvements?
              2. Is it better to keep the fuzzy step separate from the inverted index or is there a way to combine them?
            ...

            ANSWER

            Answered 2017-Oct-12 at 20:42

            You should be able to achieve what you want using Lunr, here is a simplified example (and a jsfiddle):

            Source https://stackoverflow.com/questions/46619537

            QUESTION

            How to handle async loop?
            Asked 2017-Jul-31 at 06:50

            I'm currently working on a project to implement a full-text search client-side in JavaScript based on lunr.js.

            The thing is, I'm struggling in building then saving the index because I have several asynchronous calls.

            ...

            ANSWER

            Answered 2017-Jul-28 at 14:12

            There are four problems:

            • Your function buildIndex does not return the promise, so one cannot wait for the result when calling it
            • When encountering a directory, you call buildIndex recursively but don't try to wait for its result like you did with promesse in the else case.
            • You have the promesses.push(promesse); call inside the asynchronous callback that executes only after the file was read in. The idea of putting the promise in the array is right, but you must do it immediately so that it happens before Promise.all is called upon the array.
            • You for some reason removed Promise.all from the code.

            Basically the function should have this general schema:

            Source https://stackoverflow.com/questions/45354163

            QUESTION

            elasticlunr.js not showing results for search query
            Asked 2017-Feb-15 at 03:52

            I used elasticlunr.js search engine.

            I edited their example source code

            ...

            ANSWER

            Answered 2017-Feb-14 at 09:07

            The input tag exists in between the form tag. This implies that upon pressing enter the form is submitted and therefore the page reloads thus removing any information you placed and showing the unadulterated results .

            In the example provided by the developer, $('input').bind('keyup', debounce(function () { is used. Therefore, upon entering text the tags are searched. However, in your case, the control doesn't even shift to code that you are intending to run.

            Please check this https://jsfiddle.net/kaminasw/rqj68xt5/ where it should show alert upon pressing enter in the input.

            Source https://stackoverflow.com/questions/42220460

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install lunr.js

            Simply include the lunr.js source file in the page that you want to use it. Lunr.js is supported in all modern browsers. Alternatively an npm package is also available npm install lunr. Browsers that do not support ES5 will require a JavaScript shim for Lunr to work. You can either use Augment.js, ES5-Shim or any library that patches old browsers to provide an ES5 compatible JavaScript environment.

            Support

            See the CONTRIBUTING.md file.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/olivernn/lunr.js.git

          • CLI

            gh repo clone olivernn/lunr.js

          • sshUrl

            git@github.com:olivernn/lunr.js.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link