Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
es-version:
- "7.17.6"
- "8.17.1"
es-dsl-version:
- "7.4.0"
- "8.17.1"
include:
# only test older ES version with python 3.10
- python-version: "3.10"
es-version: "6.8.23"
es-dsl-version: "6.4.0"
# we need to include this however to be sure it runs
- python-version: "3.10"
es-version: "7.17.6"
es-dsl-version: "7.4.0"
# but also runs with newer versions of ES
- python-version: "3.10"
es-version: "8.17.1"
es-dsl-version: "8.17.1"

env:
ES_VERSION: "${{ matrix.es-version }}"
Expand All @@ -45,7 +48,8 @@ jobs:
run: |
pip install -r requirements-dev.txt
pip install .
pip install coveralls
# coveralls yet incompatible with python3.13 yet
[[ ${{ matrix.python-version }} != 3.13 ]] && pip install coveralls
pip install elasticsearch-dsl==${{ matrix.es-dsl-version }}
- name: run tests
run: |
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
ES_VERSION ?= 7.17.5
ES_VERSION ?= 8.17.1

tests:
pytest

# integration test with ES using docker
es_tests:
docker run --name luqum_test_es --rm -d -ti -p 127.0.0.1:9200:9200 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" elasticsearch:${ES_VERSION}
( docker ps |grep luqum_test_es ) || \
docker run --name luqum_test_es --rm -d -ti -p 127.0.0.1:9200:9200 \
-e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-e "xpack.security.enabled=false" \
elasticsearch:${ES_VERSION}
# wait ES to be ready
@echo "waiting for ES to be ready"
@while ! curl -XGET "localhost:9200" >/dev/null 2>&1;do sleep 1; echo -n "."; done
Expand Down
51 changes: 51 additions & 0 deletions luqum/parsetab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'

_lr_method = 'LALR'

_lr_signature = 'leftIMPLICIT_OPleftOR_OPleftAND_OPnonassocPLUSMINUSnonassocBOOSTnonassocTOAND_OP APPROX BOOST COLUMN GREATERTHAN LBRACKET LESSTHAN LPAREN MINUS NOT OR_OP PHRASE PLUS RBRACKET REGEX RPAREN TERM TOexpression : expression OR_OP expressionexpression : expression AND_OP expressionexpression : expression expression %prec IMPLICIT_OPunary_expression : PLUS unary_expressionunary_expression : MINUS unary_expressionunary_expression : NOT unary_expressionexpression : unary_expressionunary_expression : LPAREN expression RPARENunary_expression : LBRACKET phrase_or_term TO phrase_or_term RBRACKETunary_expression : LESSTHAN phrase_or_termunary_expression : GREATERTHAN phrase_or_termunary_expression : TERM COLUMN unary_expressionunary_expression : PHRASEunary_expression : PHRASE APPROXunary_expression : unary_expression BOOSTunary_expression : TERMunary_expression : TERM APPROXunary_expression : REGEXunary_expression : TOphrase_or_term : TERM\n| PHRASE'

_lr_action_items = {'PLUS':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[3,3,-7,3,3,3,3,-19,-16,-13,-18,3,3,3,-15,-4,-5,-6,3,-20,-21,-10,-11,3,-17,-14,3,3,-8,-12,-9,]),'MINUS':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[4,4,-7,4,4,4,4,-19,-16,-13,-18,4,4,4,-15,-4,-5,-6,4,-20,-21,-10,-11,4,-17,-14,4,4,-8,-12,-9,]),'NOT':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[5,5,-7,5,5,5,5,-19,-16,-13,-18,-3,5,5,-15,-4,-5,-6,5,-20,-21,-10,-11,5,-17,-14,-1,-2,-8,-12,-9,]),'LPAREN':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[6,6,-7,6,6,6,6,-19,-16,-13,-18,-3,6,6,-15,-4,-5,-6,6,-20,-21,-10,-11,6,-17,-14,-1,-2,-8,-12,-9,]),'LBRACKET':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[7,7,-7,7,7,7,7,-19,-16,-13,-18,-3,7,7,-15,-4,-5,-6,7,-20,-21,-10,-11,7,-17,-14,-1,-2,-8,-12,-9,]),'LESSTHAN':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[9,9,-7,9,9,9,9,-19,-16,-13,-18,-3,9,9,-15,-4,-5,-6,9,-20,-21,-10,-11,9,-17,-14,-1,-2,-8,-12,-9,]),'GREATERTHAN':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[10,10,-7,10,10,10,10,-19,-16,-13,-18,-3,10,10,-15,-4,-5,-6,10,-20,-21,-10,-11,10,-17,-14,-1,-2,-8,-12,-9,]),'TERM':([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,33,34,36,],[11,11,-7,11,11,11,11,23,-19,23,23,-16,-13,-18,-3,11,11,-15,-4,-5,-6,11,-20,-21,-10,-11,11,-17,-14,-1,-2,-8,23,-12,-9,]),'PHRASE':([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,33,34,36,],[12,12,-7,12,12,12,12,24,-19,24,24,-16,-13,-18,-3,12,12,-15,-4,-5,-6,12,-20,-21,-10,-11,12,-17,-14,-1,-2,-8,24,-12,-9,]),'REGEX':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,36,],[13,13,-7,13,13,13,13,-19,-16,-13,-18,-3,13,13,-15,-4,-5,-6,13,-20,-21,-10,-11,13,-17,-14,-1,-2,-8,-12,-9,]),'TO':([0,1,2,3,4,5,6,8,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,36,],[8,8,-7,8,8,8,8,-19,-16,-13,-18,8,8,8,-15,-4,-5,-6,8,33,-20,-21,-10,-11,8,-17,-14,8,8,-8,-12,-9,]),'$end':([1,2,8,11,12,13,14,17,18,19,20,23,24,25,26,28,29,30,31,32,34,36,],[0,-7,-19,-16,-13,-18,-3,-15,-4,-5,-6,-20,-21,-10,-11,-17,-14,-1,-2,-8,-12,-9,]),'OR_OP':([1,2,8,11,12,13,14,17,18,19,20,21,23,24,25,26,28,29,30,31,32,34,36,],[15,-7,-19,-16,-13,-18,15,-15,-4,-5,-6,15,-20,-21,-10,-11,-17,-14,-1,-2,-8,-12,-9,]),'AND_OP':([1,2,8,11,12,13,14,17,18,19,20,21,23,24,25,26,28,29,30,31,32,34,36,],[16,-7,-19,-16,-13,-18,16,-15,-4,-5,-6,16,-20,-21,-10,-11,-17,-14,16,-2,-8,-12,-9,]),'RPAREN':([2,8,11,12,13,14,17,18,19,20,21,23,24,25,26,28,29,30,31,32,34,36,],[-7,-19,-16,-13,-18,-3,-15,-4,-5,-6,32,-20,-21,-10,-11,-17,-14,-1,-2,-8,-12,-9,]),'BOOST':([2,8,11,12,13,17,18,19,20,23,24,25,26,28,29,32,34,36,],[17,-19,-16,-13,-18,-15,17,17,17,-20,-21,-10,-11,-17,-14,-8,17,-9,]),'COLUMN':([11,],[27,]),'APPROX':([11,12,],[28,29,]),'RBRACKET':([23,24,35,],[-20,-21,36,]),}

_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items

_lr_goto_items = {'expression':([0,1,6,14,15,16,21,30,31,],[1,14,21,14,30,31,14,14,14,]),'unary_expression':([0,1,3,4,5,6,14,15,16,21,27,30,31,],[2,2,18,19,20,2,2,2,2,2,34,2,2,]),'phrase_or_term':([7,9,10,33,],[22,25,26,35,]),}

_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> expression","S'",1,None,None,None),
('expression -> expression OR_OP expression','expression',3,'p_expression_or','parser.py',252),
('expression -> expression AND_OP expression','expression',3,'p_expression_and','parser.py',258),
('expression -> expression expression','expression',2,'p_expression_implicit','parser.py',264),
('unary_expression -> PLUS unary_expression','unary_expression',2,'p_expression_plus','parser.py',270),
('unary_expression -> MINUS unary_expression','unary_expression',2,'p_expression_minus','parser.py',276),
('unary_expression -> NOT unary_expression','unary_expression',2,'p_expression_not','parser.py',282),
('expression -> unary_expression','expression',1,'p_expression_unary','parser.py',288),
('unary_expression -> LPAREN expression RPAREN','unary_expression',3,'p_grouping','parser.py',293),
('unary_expression -> LBRACKET phrase_or_term TO phrase_or_term RBRACKET','unary_expression',5,'p_range','parser.py',299),
('unary_expression -> LESSTHAN phrase_or_term','unary_expression',2,'p_lessthan','parser.py',307),
('unary_expression -> GREATERTHAN phrase_or_term','unary_expression',2,'p_greaterthan','parser.py',314),
('unary_expression -> TERM COLUMN unary_expression','unary_expression',3,'p_field_search','parser.py',321),
('unary_expression -> PHRASE','unary_expression',1,'p_quoting','parser.py',330),
('unary_expression -> PHRASE APPROX','unary_expression',2,'p_proximity','parser.py',335),
('unary_expression -> unary_expression BOOST','unary_expression',2,'p_boosting','parser.py',341),
('unary_expression -> TERM','unary_expression',1,'p_terms','parser.py',347),
('unary_expression -> TERM APPROX','unary_expression',2,'p_fuzzy','parser.py',352),
('unary_expression -> REGEX','unary_expression',1,'p_regex','parser.py',358),
('unary_expression -> TO','unary_expression',1,'p_to_as_term','parser.py',364),
('phrase_or_term -> TERM','phrase_or_term',1,'p_phrase_or_term','parser.py',370),
('phrase_or_term -> PHRASE','phrase_or_term',1,'p_phrase_or_term','parser.py',371),
]
14 changes: 7 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-r requirements.txt

coverage==6.4.2
elasticsearch-dsl==7.4.0
flake8==4.0.1
pytest==7.1.2
pytest-cov==3.0.0
Sphinx==5.1.1
wheel==0.38.1
coverage==7.6.10
elasticsearch-dsl==8.17.1
flake8==7.1.1
pytest==8.3.4
pytest-cov==6.0.0
Sphinx==8.1.3
wheel==0.45.1
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
'License :: OSI Approved :: Apache Software License',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
],
)
6 changes: 4 additions & 2 deletions tests/test_elasticsearch/es_integration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def get_es():
# launching something like
# docker run --rm -p "127.0.0.1:9200:9200" -e "discovery.type=single-node" elasticsearch:7.8.0
# is a simple way to get an instance
connections.configure(default=dict(hosts=os.environ.get("ES_HOST", "localhost"), timeout=20))
connections.configure(
default=dict(hosts=os.environ.get("ES_HOST", "http://localhost:9200"), timeout=20)
)
try:
client = connections.get_connection("default")
# check ES running
Expand All @@ -61,7 +63,7 @@ class Book(Document):
"""
title = Text(fields={
"no_vowels": Text(
analyzer=analyzer("no_vowels", "pattern", pattern="[\Waeiouy]"), # noqa: W605
analyzer=analyzer("no_vowels", "pattern", pattern=r"[\Waeiouy]"), # noqa: W605
search_analyzer="standard"
)
})
Expand Down