Package: luqum
luqum - A lucene query parser in Python, using PLY“luqum” (as in LUcene QUery Manipolator) is a tool to parse queries
written in theLucene Query DSLand 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 nativeElasticSearch JSON DSLThanks 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.6+Installationpip install luqumDependenciesPLY>= 3.11Full documentationhttp://luqum.readthedocs.org/en/latest/Changelog for luqumThe format is based onKeep a Changelogand this project tries to adhere toSemantic Versioning.0.13.0 - 2023-03-24AddedAdd support for unbounded rangesSupport 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<=fooa lot
less complicated.There is no support in the ElasticsearchQueryBuilder.0.12.1 - 2023-02-08FixedPrecedence for unknown operation and boost (#89, thanks to @JSCU-CNI)0.12.0 - 2022-10-13ChangedBoost can be implicit ; by default, the boost factor is 1AddedAdd support for Lucene and Elasticsearch Boolean operations (#71, thanks to @linefeedse):Introduce the BooleanOperationadd its resolution in ElasticSearch transformeradd 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)FixedCast TokenValue.__str__ return value to string (#74, thanks to @delkopiso)Isolated comma should be parsed as a Word (#80)Better handling of escaped wildcardsDocsAdd boolean operation to docFix quick start documentationUpdated readthedocs instructionsCIRun tests with github actionsUpdate all libraries for dev:switch from nose to pytest as nose is not python3.10 compatibleremove old travis tests0.11.0 - 2021-01-06Changedcompletely modified the naming module andauto_namefunction, as it was not practical as is.Addedadded tools to build visual explanations about why a request matches a results
(leveragingelasticsearch named queries.added a visitor and transformer that tracks path to element while visiting the tree.Fixedfixed the handling of names when transforming luqum tree to elasticsearch queries
and added integration tests.0.10.0 - 2020-09-22Addedsupport for parsing Regular expressions like/foo/(no transformation to Elasticsearch DSL yet)basic support for head and tail of expressions (the separators)
and for their position (pos and size) in original textaddedauto_head_tailutil
(use it if you build your tree programatically and want a printable representation)tree item now support aclone_itemmethod and a setter for children.
This should help with making transformation pattern easier.Newvisitor.TreeVisitorandvisitor.TreeTransformerclasses to help in processing treesutils.LuceneTreeVisitor,utils.LuceneTreeVisitorV2andutils.LuceneTreeTransformerare warned as deprecated (but still works).Changedsupport for python 3.8 added, support for python 3.4 and 3.5 droppedbetter printing of Proximity and Fuzzy items (preserve implicit nature of degree)raiseIllegalCharacterErroron illegal character found instead of printing and skippingrenamedParseErrortoParseSyntaxError, and keptParseErroras a parent exceptionFixedRange item were not checking for bounds type on equalityBoost item were not checking for force on equalityReorganize tests0.9.0 - 2020-07-29Addedsupport for elasticsearch 70.8.1 - 2019-11-01Addedadded Apache 2 license, while maintaining LGPLv3+0.8.0 - 2019-08-02Addedsupport formulti_matchquery inElasticsearchQueryBuilder.FixedSchemaAnalyzer, should count non text fields as not_analyzedElasticsearchQueryBuilder’sfield_optionsparameter
can acceptmatch_typeinstead oftypeto change request type.
This is now the prefered way overtypewhich may more easily conflict with request parameters.0.7.5 - 2018-10-29Addedhandling sub fields (akamulti-fields)Fixedfixed bug on equality, having more children in one tree than in the other,
was not triggering inequality if first nodes were the same !0.7.4 - 2018-08-28Addedhandlingspecial characters escapingaddediter_wildcardsandsplit_wildcardsto have a finer grained search of wildcard in termsFixedfixed bug inluqum.utils.LuceneTreeTransformerwhen removing nodefixed bug in handling approx operator on multiple words inluqum.elasticsearch.visitor.ElasticsearchQueryBuildertest coverage now check branch0.7.3 - 2018-06-08FixedOn ElasticSearch query transformation, Luqum was interpreting wildcards in Phrases where as it should not0.7.2 - 2018-05-14Fixedadding thezero_terms_querytomatch_phrasewas a mistake (introduced in 0.7.0).Added0.7.0 introduced thematchquery for queries with single words on analyzed fields,
whereas before it was usingmatch_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 newmatch_word_as_phraseparameter
toluqum.elasticsearch.visitor.ElasticsearchQueryBuilder.
Note that this parameter maybe removed in future release.
(thefield_optionsmight be used instead on a per field basis).0.7.1 - 2018-03-20Fixedversion introduced because of a bad upload on pypi (Restructured description error)0.7.0 - 2018-03-20AddedSupport for named queries (seeelastic named queries)Helper to automatically create ElasticSearch query builder options from the index configuration,
see:luqum.elasticsearch.schemaa new argfield_optionsonluqum.elasticsearch.visitor.ElasticsearchQueryBuilderallows 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.Fixedsmall fix in utils.TreeTransformerV2,
which was not removing elements from lists or tuple as statedsingle word matches, are nowmatch, and notmatch_phrasematch_phrasehas thezero_terms_queryfield, as formatchChangeddropped official Python 3.3 support0.6.0 - 2017-12-12AddedManage object fields in elasicsearch transformationFixedminor fix, getting better error message when parsing error is at the end of contentChangedbetter handling of nested fields may lead to shorter requests0.5.3 - 2017-08-21AddedA class to transform smartly replace implicit operations with explicit one (ORorAND)Fixedhandling of fields names with numbers followed by a number
(better handling of time in expressions)Changednow using ply 3.100.5.2 - 2017-05-29Changedbetter recursion in the tree transformer util (API Change)Fixedhandling of empty phrases for elasticsearch query builder0.5.1 - 2017-04-10a minor releaseChangedBetter handling of the implicit operator on printing0.5.0 - 2017-04-04ChangedOperations are now supporting multiple operands (instead of only two).
This mitigate the construction of very deep trees.Fixedfixes and improvement of documentation0.4.0 - 2016-12-05ChangedThe Lucene query checker now checks nested fields before transformation to prevent bad usage0.3.1 - 2016-11-23AddedSupport for nested fields in Elastic Search queriesChangedimproved performances by adding a cache to the tree visitor utility0.3 - 2016-11-21(Note that 0.2 version was skipped)AddedTransforming Lucene queries to Elastic Search queriesAdded a new tree visitorTreeVisitorV2more easy to useFixedImproved first tree visitor utility and its tests (API Change)0.1 - 2016-05-17This was the initial release of Luqum.Addedthe parser and the tree structurethe visitor and transformer utilsthe Lucene query consistency checkerthe prettify for pretty printing