Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
eb8aa0ef
Commit
eb8aa0ef
authored
Oct 29, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! full text: move special query generation logic from SearchKey to ComparisonOperator.
parent
36a82398
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
21 deletions
+6
-21
product/ZSQLCatalog/Operator/ComparisonOperator.py
product/ZSQLCatalog/Operator/ComparisonOperator.py
+6
-21
No files found.
product/ZSQLCatalog/Operator/ComparisonOperator.py
View file @
eb8aa0ef
...
...
@@ -139,6 +139,10 @@ class MroongaComparisonOperator(MatchComparisonOperator):
fulltext_boolean_splitter
=
re
.
compile
(
r'(\
s|
\(.+?\
)|
".+?")'
)
fulltext_boolean_detector
=
re
.
compile
(
r'(^[+-]|^.+\
*$|^[
"(].+[")]$)'
)
def
__init__
(
self
,
operator
,
force_boolean
=
False
):
MatchComparisonOperator
.
__init__
(
self
,
operator
,
' IN BOOLEAN MODE'
)
self
.
force_boolean
=
force_boolean
def
renderValue
(
self
,
value_list
):
"""
Special Query renderer for MroongaFullText queries:
...
...
@@ -151,7 +155,7 @@ class MroongaComparisonOperator(MatchComparisonOperator):
except
ValueError
:
raise
ValueError
,
'%r: value_list must not contain more than one item. Got %r'
%
(
self
,
value_list
)
if
self
.
mode
==
' IN BOOLEAN MODE'
:
if
self
.
force_boolean
:
fulltext_query
=
'*D+ %s'
%
value_list
return
self
.
_renderValue
(
fulltext_query
)
else
:
...
...
@@ -166,7 +170,6 @@ class MroongaComparisonOperator(MatchComparisonOperator):
else
:
match_query_list
.
append
(
token
)
# Always use BOOLEAN MODE to combine similarity search and boolean search.
self
.
mode
=
' IN BOOLEAN MODE'
fulltext_query
=
'*D+'
if
match_query_list
:
fulltext_query
+=
' *S"%s"'
%
' '
.
join
(
x
.
replace
(
'"'
,
'
\
\
"'
)
for
x
in
match_query_list
)
...
...
@@ -176,24 +179,6 @@ class MroongaComparisonOperator(MatchComparisonOperator):
verifyClass
(
IOperator
,
MroongaComparisonOperator
)
class
MroongaBooleanComparisonOperator
(
MroongaComparisonOperator
):
def
renderValue
(
self
,
value_list
):
"""
Special Query renderer for MroongaFullText queries:
* by default 'AND' search by using '*D+' pragma.
"""
if
isinstance
(
value_list
,
list_type_list
):
try
:
value_list
,
=
value_list
except
ValueError
:
raise
ValueError
,
'%r: value_list must not contain more than one item. Got %r'
%
(
self
,
value_list
)
fulltext_query
=
'*D+ %s'
%
value_list
print
self
.
_renderValue
(
fulltext_query
)
return
self
.
_renderValue
(
fulltext_query
)
verifyClass
(
IOperator
,
MatchComparisonOperator
)
class
SphinxSEComparisonOperator
(
MonovaluedComparisonOperator
):
def
__init__
(
self
,
operator
,
mode
=
''
):
MonovaluedComparisonOperator
.
__init__
(
self
,
operator
,
''
)
...
...
@@ -241,7 +226,7 @@ operator_dict = {
'match_boolean'
:
MatchComparisonOperator
(
'match_boolean'
,
mode
=
' IN BOOLEAN MODE'
),
'match_expansion'
:
MatchComparisonOperator
(
'match_expansion'
,
mode
=
' WITH QUERY EXPANSION'
),
'mroonga'
:
MroongaComparisonOperator
(
'mroonga'
),
'mroonga_boolean'
:
MroongaComparisonOperator
(
'mroonga_boolean'
,
mode
=
' IN BOOLEAN MODE'
),
'mroonga_boolean'
:
MroongaComparisonOperator
(
'mroonga_boolean'
,
force_boolean
=
True
),
'sphinxse'
:
SphinxSEComparisonOperator
(
'sphinxse'
),
'in'
:
MultivaluedComparisonOperator
(
'in'
),
'is'
:
MonovaluedComparisonOperator
(
'is'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment