A Lucene query parser generating ElasticSearch queries and more !
luqum - A lucene query parser in Python, using PLY
“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.
Compatible with Python 3.4+
pip install luqum
PLY >= 3.11
Changelog for luqum
0.7.4 - 2018-08-28
- handling special characters escaping
- added iter_wildcards and split_wildcards to have a finer grained search of wildcard in terms
- fixed bug in luqum.utils.LuceneTreeTransformer when removing node
- fixed bug in handling approx operator on multiple words in luqum.elasticsearch.visitor.ElasticsearchQueryBuilder
- test coverage now check branch
0.7.3 - 2018-06-08
- On ElasticSearch query transformation, Luqum was interpreting wildcards in Phrases where as it should not
0.7.2 - 2018-05-14
- adding the zero_terms_query to match_phrase was a mistake (introduced in 0.7.0).
0.7.0 introduced the match query for queries with single words on analyzed fields, whereas before it was using match_phrase. Although this is more coherent, this may cause difficulties on edge cases as this may leads to results different from previous release.
This behaviour might be disabled using a new match_word_as_phrase parameter to luqum.elasticsearch.visitor.ElasticsearchQueryBuilder. Note that this parameter maybe removed in future release. (the field_options might be used instead on a per field basis).
0.7.1 - 2018-03-20
- version introduced because of a bad upload on pypi (Restructured description error)
0.7.0 - 2018-03-20
- Support for named queries (see elastic named queries)
- Helper to automatically create ElasticSearch query builder options from the index configuration, see: luqum.elasticsearch.schema
- a new arg field_options on luqum.elasticsearch.visitor.ElasticsearchQueryBuilder allows to add parameters to field queries. It also permits to control the type of query for match queries.
- now for a query with a single word, if the field is analyzed, the transformation to elastic search query will use a “match” query instead of a “match_phrase”. This is more conform in behaviour to what the expression of “query_string” would produce.
- small fix in utils.TreeTransformerV2, which was not removing elements from lists or tuple as stated
- single word matches, are now match, and not match_phrase
- match_phrase has the zero_terms_query field, as for match
- dropped official Python 3.3 support
0.6.0 - 2017-12-12
- Manage object fields in elasicsearch transformation
- minor fix, getting better error message when parsing error is at the end of content
- better handling of nested fields may lead to shorter requests
0.5.3 - 2017-08-21
- A class to transform smartly replace implicit operations with explicit one (OR or AND)
- handling of fields names with numbers followed by a number (better handling of time in expressions)
- now using ply 3.10
0.5.2 - 2017-05-29
- better recursion in the tree transformer util (API Change)
- handling of empty phrases for elasticsearch query builder
0.5.1 - 2017-04-10
a minor release
- Better handling of the implicit operator on printing
0.5.0 - 2017-04-04
- Operations are now supporting multiple operands (instead of only two). This mitigate the construction of very deep trees.
- fixes and improvement of documentation
0.4.0 - 2016-12-05
- The Lucene query checker now checks nested fields before transformation to prevent bad usage
0.3.1 - 2016-11-23
- Support for nested fields in Elastic Search queries
- improved performances by adding a cache to the tree visitor utility
0.3 - 2016-11-21
(Note that 0.2 version was skipped)
- Transforming Lucene queries to Elastic Search queries
- Added a new tree visitor TreeVisitorV2 more easy to use
- Improved first tree visitor utility and its tests (API Change)
0.1 - 2016-05-17
This was the initial release of Luqum.
- the parser and the tree structure
- the visitor and transformer utils
- the Lucene query consistency checker
- the prettify for pretty printing
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|luqum-0.7.4.linux-x86_64.tar.gz (62.7 kB) Copy SHA256 hash SHA256||Source||None||Aug 28, 2018|
|luqum-0.7.4-py3-none-any.whl (35.8 kB) Copy SHA256 hash SHA256||Wheel||py3||Aug 28, 2018|