lunr


Namelunr JSON
Version 0.7.0.post1 PyPI version JSON
download
home_page
SummaryA Python implementation of Lunr.js
upload_time2023-08-16 16:51:34
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords full lunr search text
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/yeraydiazdiaz/lunr.py/workflows/CI/badge.svg?branch=master)](https://github.com/yeraydiazdiaz/lunr.py/actions?workflow=CI)
[![codecov](https://codecov.io/gh/yeraydiazdiaz/lunr.py/branch/master/graph/badge.svg)](https://codecov.io/gh/yeraydiazdiaz/lunr.py)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/lunr.svg)](https://pypi.org/project/lunr/)
[![PyPI](https://img.shields.io/pypi/v/lunr.svg)](https://pypi.org/project/lunr/)
[![Read the Docs](https://img.shields.io/readthedocs/lunr.svg)](http://lunr.readthedocs.io/en/latest/)
[![Downloads](http://pepy.tech/badge/lunr)](http://pepy.tech/project/lunr)

# Lunr.py

A Python implementation of [Lunr.js](https://lunrjs.com) by [Oliver Nightingale](https://github.com/olivernn).

> A bit like Solr, but much smaller and not as bright.

This Python version of Lunr.js aims to bring the simple and powerful full text search
capabilities into Python guaranteeing results as close as the original
implementation as possible.

- [Documentation](http://lunr.readthedocs.io/en/latest/)

## What does this even do?

Lunr is a simple full text search solution for situations where deploying a full
scale solution like Elasticsearch isn't possible, viable or you're simply prototyping.
Lunr parses a set of documents and creates an inverted index for quick full text
searches in the same way other more complicated solution.

The trade-off is that Lunr keeps the inverted index in memory and requires you
to recreate or read the index at the start of your application.

## Interoperability with Lunr.js

A core objective of Lunr.py is to provide
[interoperability with the JavaScript version](https://lunr.readthedocs.io/en/latest/lunrjs-interop).

An example can be found in the [MkDocs documentation library](http://www.mkdocs.org/).
MkDocs produces a set of documents from the pages of the documentation and uses
[Lunr.js](https://lunrjs.com) in the frontend to power its built-in searching
engine. This set of documents is in the form of a JSON file which needs to be
fetched and parsed by Lunr.js to create the inverted index at startup of your application.

While this is not a problem for most sites, depending on the size of your document
set, this can take some time.

Lunr.py provides a backend solution, allowing you to parse the documents in Python
of time and create a serialized Lunr.js index you can pass have the browser
version read, minimizing start up time of your application.

Each version of lunr.py
[targets a specific version of lunr.js](https://github.com/yeraydiazdiaz/lunr.py/blob/master/lunr/__init__.py#L12)
and produces the same results for a
[non-trivial corpus of documents](https://github.com/yeraydiazdiaz/lunr.py/blob/master/tests/acceptance_tests/fixtures/mkdocs_index.json).

## Installation

`pip install lunr`

An optional and experimental support for other languages thanks to the
[Natural Language Toolkit](http://www.nltk.org/) stemmers is also available via
`pip install lunr[languages]`. The usage of the language feature is subject to
[NTLK corpus licensing clauses](https://github.com/nltk/nltk#redistributing).

Please refer to the
[documentation page on languages](https://lunr.readthedocs.io/en/latest/languages.html)
for more information.

## Usage

First, you'll need a list of dicts representing the documents you want to search on.
These documents must have a unique field which will serve as a reference and a
series of fields you'd like to search on.

Lunr provides a convenience `lunr` function to quickly index this set of documents:

```python
>>> from lunr import lunr
>>>
>>> documents = [{
...     'id': 'a',
...     'title': 'Mr. Green kills Colonel Mustard',
...     'body': 'Mr. Green killed Colonel Mustard in the study with the candlestick.',
... }, {
...     'id': 'b',
...     'title': 'Plumb waters plant',
...     'body': 'Professor Plumb has a green plant in his study',
... }]
>>> idx = lunr(
...     ref='id', fields=('title', 'body'), documents=documents
... )
>>> idx.search('kill')
[{'ref': 'a', 'score': 0.6931722372559913, 'match_data': <MatchData "kill">}]
>>> idx.search('study')
[{'ref': 'b', 'score': 0.23576799568081389, 'match_data': <MatchData "studi">}, {'ref': 'a', 'score': 0.2236629211724517, 'match_data': <MatchData "studi">}]
```

Please refer to the [documentation](http://lunr.readthedocs.io/en/latest/)
for more usage examples.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "lunr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "full,lunr,search,text",
    "author": "",
    "author_email": "Yeray Diaz Diaz <yeraydiazdiaz@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8b/92/885c5e6251b76d3a171ff757a4e167cbb44c02fd9aff67b545a246778a6a/lunr-0.7.0.post1.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/yeraydiazdiaz/lunr.py/workflows/CI/badge.svg?branch=master)](https://github.com/yeraydiazdiaz/lunr.py/actions?workflow=CI)\n[![codecov](https://codecov.io/gh/yeraydiazdiaz/lunr.py/branch/master/graph/badge.svg)](https://codecov.io/gh/yeraydiazdiaz/lunr.py)\n[![Supported Python Versions](https://img.shields.io/pypi/pyversions/lunr.svg)](https://pypi.org/project/lunr/)\n[![PyPI](https://img.shields.io/pypi/v/lunr.svg)](https://pypi.org/project/lunr/)\n[![Read the Docs](https://img.shields.io/readthedocs/lunr.svg)](http://lunr.readthedocs.io/en/latest/)\n[![Downloads](http://pepy.tech/badge/lunr)](http://pepy.tech/project/lunr)\n\n# Lunr.py\n\nA Python implementation of [Lunr.js](https://lunrjs.com) by [Oliver Nightingale](https://github.com/olivernn).\n\n> A bit like Solr, but much smaller and not as bright.\n\nThis Python version of Lunr.js aims to bring the simple and powerful full text search\ncapabilities into Python guaranteeing results as close as the original\nimplementation as possible.\n\n- [Documentation](http://lunr.readthedocs.io/en/latest/)\n\n## What does this even do?\n\nLunr is a simple full text search solution for situations where deploying a full\nscale solution like Elasticsearch isn't possible, viable or you're simply prototyping.\nLunr parses a set of documents and creates an inverted index for quick full text\nsearches in the same way other more complicated solution.\n\nThe trade-off is that Lunr keeps the inverted index in memory and requires you\nto recreate or read the index at the start of your application.\n\n## Interoperability with Lunr.js\n\nA core objective of Lunr.py is to provide\n[interoperability with the JavaScript version](https://lunr.readthedocs.io/en/latest/lunrjs-interop).\n\nAn example can be found in the [MkDocs documentation library](http://www.mkdocs.org/).\nMkDocs produces a set of documents from the pages of the documentation and uses\n[Lunr.js](https://lunrjs.com) in the frontend to power its built-in searching\nengine. This set of documents is in the form of a JSON file which needs to be\nfetched and parsed by Lunr.js to create the inverted index at startup of your application.\n\nWhile this is not a problem for most sites, depending on the size of your document\nset, this can take some time.\n\nLunr.py provides a backend solution, allowing you to parse the documents in Python\nof time and create a serialized Lunr.js index you can pass have the browser\nversion read, minimizing start up time of your application.\n\nEach version of lunr.py\n[targets a specific version of lunr.js](https://github.com/yeraydiazdiaz/lunr.py/blob/master/lunr/__init__.py#L12)\nand produces the same results for a\n[non-trivial corpus of documents](https://github.com/yeraydiazdiaz/lunr.py/blob/master/tests/acceptance_tests/fixtures/mkdocs_index.json).\n\n## Installation\n\n`pip install lunr`\n\nAn optional and experimental support for other languages thanks to the\n[Natural Language Toolkit](http://www.nltk.org/) stemmers is also available via\n`pip install lunr[languages]`. The usage of the language feature is subject to\n[NTLK corpus licensing clauses](https://github.com/nltk/nltk#redistributing).\n\nPlease refer to the\n[documentation page on languages](https://lunr.readthedocs.io/en/latest/languages.html)\nfor more information.\n\n## Usage\n\nFirst, you'll need a list of dicts representing the documents you want to search on.\nThese documents must have a unique field which will serve as a reference and a\nseries of fields you'd like to search on.\n\nLunr provides a convenience `lunr` function to quickly index this set of documents:\n\n```python\n>>> from lunr import lunr\n>>>\n>>> documents = [{\n...     'id': 'a',\n...     'title': 'Mr. Green kills Colonel Mustard',\n...     'body': 'Mr. Green killed Colonel Mustard in the study with the candlestick.',\n... }, {\n...     'id': 'b',\n...     'title': 'Plumb waters plant',\n...     'body': 'Professor Plumb has a green plant in his study',\n... }]\n>>> idx = lunr(\n...     ref='id', fields=('title', 'body'), documents=documents\n... )\n>>> idx.search('kill')\n[{'ref': 'a', 'score': 0.6931722372559913, 'match_data': <MatchData \"kill\">}]\n>>> idx.search('study')\n[{'ref': 'b', 'score': 0.23576799568081389, 'match_data': <MatchData \"studi\">}, {'ref': 'a', 'score': 0.2236629211724517, 'match_data': <MatchData \"studi\">}]\n```\n\nPlease refer to the [documentation](http://lunr.readthedocs.io/en/latest/)\nfor more usage examples.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python implementation of Lunr.js",
    "version": "0.7.0.post1",
    "project_urls": {
        "Bug Tracker": "https://github.com/yeraydiazdiaz/lunr.py/issues",
        "Changelog": "https://github.com/yeraydiazdiaz/lunr.py/blob/master/CHANGELOG.md",
        "Documentation": "https://lunr.readthedocs.io/en/latest/",
        "Source Code": "https://github.com/yeraydiazdiaz/lunr.py"
    },
    "split_keywords": [
        "full",
        "lunr",
        "search",
        "text"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "516c9209b793fc98f9211846f3b2ec63e0780d30c26b9a0f2985100430dcd238",
                "md5": "ca501dd74b1679bf539263712d2862c9",
                "sha256": "77cce585d195d412cff362698799c9571ff3e285fc6bd8816ecbc9ec82dbb368"
            },
            "downloads": -1,
            "filename": "lunr-0.7.0.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca501dd74b1679bf539263712d2862c9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 35209,
            "upload_time": "2023-08-16T16:51:31",
            "upload_time_iso_8601": "2023-08-16T16:51:31.589161Z",
            "url": "https://files.pythonhosted.org/packages/51/6c/9209b793fc98f9211846f3b2ec63e0780d30c26b9a0f2985100430dcd238/lunr-0.7.0.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b92885c5e6251b76d3a171ff757a4e167cbb44c02fd9aff67b545a246778a6a",
                "md5": "bc1449d0bd8e92c4c2ee688d20ff5e5f",
                "sha256": "00fc98f59b53c7ee0f6384c99e6c099f28cb746ecfff865bbc3705c3e9104bda"
            },
            "downloads": -1,
            "filename": "lunr-0.7.0.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "bc1449d0bd8e92c4c2ee688d20ff5e5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 1146070,
            "upload_time": "2023-08-16T16:51:34",
            "upload_time_iso_8601": "2023-08-16T16:51:34.135911Z",
            "url": "https://files.pythonhosted.org/packages/8b/92/885c5e6251b76d3a171ff757a4e167cbb44c02fd9aff67b545a246778a6a/lunr-0.7.0.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-16 16:51:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yeraydiazdiaz",
    "github_project": "lunr.py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "lunr"
}
        
Elapsed time: 0.54335s