# luqum

> A Lucene query parser generating ElasticSearch queries and more !

- **URL**: https://www.freshcrate.ai/projects/luqum
- **Author**: Jurismarches
- **Category**: RAG & Memory
- **Latest version**: `1.0.0` (2026-04-21)
- **License**: Unknown
- **Source**: https://github.com/jurismarches/luqum
- **Language**: Python
- **GitHub**: 200 stars, 42 forks
- **Registry**: pypi (`luqum`)
- **Tags**: `pypi`

## Description

luqum - A lucene query parser in Python, using PLY
#########################################################

|pypi-version| |readthedocs| |travis| |coveralls|

|logo|

"luqum" (as in LUcene QUery Manipolator) is a tool to parse queries
written in the `Lucene Query DSL`_ and build an abstract syntax tree
to inspect, analyze or otherwise manipulate search queries.

It enables enriching the Lucene Query DSL meanings
(for example to support nested object searches or have particular treatments on some fields),
and transform lucene DSL queries to native `ElasticSearch JSON DSL`_

Thanks to luqum, your users may continue to write queries like:
`author.last_name:Smith OR author:(age:[25 TO 34] AND first_name:John)`
and you will be able to leverage ElasticSearch query DSL,
and control the precise meaning of each search terms.

Luqum is dual licensed under Apache2.0 and LGPLv3.

Compatible with Python 3.10+

Installation
============

``pip install luqum``


Dependencies
============

`PLY`_ >= 3.11


Full documentation
==================

http://luqum.readthedocs.org/en/latest/


.. _`Lucene Query DSL` : https://lucene.apache.org/core/3_6_0/queryparsersyntax.html
.. _`ElasticSearch JSON DSL`: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

.. _`PLY`: http://www.dabeaz.com/ply/

.. |logo| image:: https://raw.githubusercontent.com/jurismarches/luqum/master/luqum-logo.png

.. |pypi-version| image:: https://img.shields.io/pypi/v/luqum.svg
    :target: https://pypi.python.org/pypi/luqum
    :alt: Latest PyPI version
.. |travis| image:: http://img.shields.io/travis/jurismarches/luqum/master.svg?style=flat
    :target: https://travis-ci.org/jurismarches/luqum
.. |coveralls| image:: http://img.shields.io/coveralls/jurismarches/luqum/master.svg?style=flat
    :target: https://coveralls.io/r/jurismarches/luqum
.. |readthedocs| image:: https://readthedocs.org/projects/luqum/badge/?version=latest
    :target: http://luqum.readthedocs.org/en/latest/?badge=latest
    :alt: Documentation Status




Changelog for luqum
###################

The format is based on `Keep a Changelog`_
and this project tries to adhere to `Semantic Versioning`_.

.. _`Keep a Changelog`: http://keepachangelog.com/en/1.0.0/
.. _`Semantic Versioning`: http://semver.org/spec/v2.0.0.html

1.0.0 - 2025-02-18
==================

Fixed
-----

* parsetab.py file
* PyPI distribution procedure for devs

Added
-----

* Requirements for build and twine for devs


0.14.0 - 2025-02-17
===================

Added
-----

* Support for Python 3.11, 3.12 and 3.13 (#97 and #111, thanks to @cclauss and @alexgarel)
* Support for negative values in range (#101, thanks to @mesemus)
* Docs on OpenRangeTransformer (#110, thanks to @alexgarel)

Removed
-------

* Support for Python 3.6, 3.7, 3.8 and 3.9 (#111, thanks to @alexgarel)

Fixed
-----

* Improved global state management for lexer (#109, thanks to @Morikko)
* Recognize E_NESTED override (#103, thanks to @maksle)


0.13.0 - 2023-03-24
===================

Added
-----

* Add support for unbounded ranges

  Support is added for open ranges, i.e. inequality operators in
  front of a term. In tree form, the < is named To, and > is named From.

  Additionally, a TreeTransformer is also added, to convert these
  open ranges to more traditional Range objects.

  To properly support escaping, some adjustments were made to how escaping
  sequences work. After careful evaluation of how Apache Lucene handles
  escape sequences, it appears that random characters can be escaped, even
  if they result in unknown escape sequences: the escaped character is
  always yielded. This makes support for operations such as `<\=foo` a lot
  less complicated.

  There is no support in the ElasticsearchQueryBuilder.

0.12.1 - 2023-02-08
===================

Fixed
-----

- Precedence for unknown operation and boost (#89, thanks to @JSCU-CNI)


0.12.0 - 2022-10-13
===================

Changed
-------

- Boost can be implicit ; by default, the boost factor is 1

Added
-----

- Add support for Lucene and Elasticsearch Boolean operations (#71, thanks to @linefeedse):

  * Introduce the BooleanOperation
  * add its resolution in ElasticSearch transformer
  * add it as a possible resolver for the unknown operation (no explicit operator in query)

- Set E element as ElasticsearchQueryBuilder's attributes (#75, thanks to @qcoumes):

  This allows to override elements such as EMust, EWord, ...,
  without the need of overriding ElasticsearchQueryBuilder's methods.

- Explicit support for Python 3.9 and Python 3.10 (#76)
- Add a thread safe parse function (#82)

Fixed
-----

- Cast TokenValue.__str__ return value to string (#74, thanks to @delkopiso)
- Isolated comma should be parsed as a Word (#80)
- Better handling of escaped wildcards

Docs
----

- Add boolean operation to doc
- Fix quick start documentation
- Updated readthedocs instructions

CI
--

- Run tests with github actions
- Update all libraries for dev:

  * switch

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `1.0.0` | 2026-04-21 | Low | Imported from PyPI (1.0.0) |
| `0.14.0` | 2025-02-17 | Low | ## What's Changed  ### Added * Support for Python 3.11, 3.12 and 3.13 ([#97](https://github.com/jurismarches/luqum/pull/97) and [#111](https://github.com/jurismarches/luqum/pull/111), thanks to @cclauss and @alexgarel) * Support for negative values in range ([#101](https://github.com/jurismarches/luqum/pull/101), thanks to @mesemus)                        * Docs on OpenRangeTransformer ([#110](https://github.com/jurismarches/luqum/pull/110), thanks to @alexgarel) |
| `0.13.0` | 2023-03-24 | Low | # Added  - Add support for unbounded ranges (#91, thanks to @JSCU-CNI) |
| `0.12.1` | 2023-02-08 | Low | # Fixed  - Precedence for unknown operation and boost (#89, thanks to @JSCU-CNI) |
| `0.12.0` | 2022-10-14 | Low | Changed                                                                                  -------                                                                                                                                                                           - Boost can be implicit ; by default, the boost factor is 1                                                                                                                       Added |
| `0.11.0` | 2021-01-06 | Low | Release 0.11.0 |

## Citation

- HTML: https://www.freshcrate.ai/projects/luqum
- Markdown: https://www.freshcrate.ai/projects/luqum.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/luqum/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
