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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
10cab70f
Commit
10cab70f
authored
Oct 24, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use similarity search for tokens without boolean operators in MroongaFullTextKey.
parent
7cfdac13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
+31
-1
No files found.
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
View file @
10cab70f
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
from
FullTextKey
import
FullTextKey
from
FullTextKey
import
FullTextKey
from
Products.ZSQLCatalog.Query.SimpleQuery
import
SimpleQuery
from
Products.ZSQLCatalog.Query.SimpleQuery
import
SimpleQuery
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
SearchKey
import
SearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
import
re
import
re
...
@@ -37,7 +38,36 @@ class MroongaFullTextKey(FullTextKey):
...
@@ -37,7 +38,36 @@ class MroongaFullTextKey(FullTextKey):
This SearchKey generates SQL fulltext comparisons for Mroonga.
This SearchKey generates SQL fulltext comparisons for Mroonga.
"""
"""
default_comparison_operator
=
'match'
default_comparison_operator
=
'match'
fulltext_boolean_detector
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-
\("]|[\
*
\)"](\
s|$))
')
fulltext_boolean_splitter
=
re
.
compile
(
r'(\
s|
\(.+?\
)|
".+?")'
)
fulltext_boolean_detector
=
re
.
compile
(
r'(^[+-]|^["(].+[")]$)'
)
def
_processSearchValue
(
self
,
search_value
,
logical_operator
,
comparison_operator
):
"""
Special SearchValue processor for MroongaFullText queries:
if a searched token from 'match' operator group contains an
operator recognised in boolean mode, make the operator for
that value be 'match_boolean'.
"""
operator_value_dict
,
logical_operator
,
parsed
=
\
SearchKey
.
_processSearchValue
(
self
,
search_value
,
logical_operator
,
comparison_operator
)
new_value_list
=
[]
append
=
new_value_list
.
append
for
value
in
operator_value_dict
.
pop
(
'match'
,
[]):
if
isinstance
(
value
,
basestring
):
for
token
in
self
.
fulltext_boolean_splitter
.
split
(
value
):
token
=
token
.
strip
()
if
not
token
:
continue
elif
self
.
fulltext_boolean_detector
.
match
(
token
):
operator_value_dict
.
setdefault
(
'match_boolean'
,
[]).
append
(
token
)
else
:
append
(
token
)
else
:
append
(
value
)
operator_value_dict
[
'match'
]
=
new_value_list
return
operator_value_dict
,
logical_operator
,
parsed
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
"""
"""
...
...
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