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
Carlos Ramos Carreño
erp5
Commits
91352eec
Commit
91352eec
authored
Oct 23, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MroongaFullTextKey and MroongaBooleanFullTextKey.
parent
acf2e5ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
2 deletions
+105
-2
product/ZSQLCatalog/SearchKey/FullTextKey.py
product/ZSQLCatalog/SearchKey/FullTextKey.py
+2
-2
product/ZSQLCatalog/SearchKey/MroongaBooleanFullTextKey.py
product/ZSQLCatalog/SearchKey/MroongaBooleanFullTextKey.py
+40
-0
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
+63
-0
No files found.
product/ZSQLCatalog/SearchKey/FullTextKey.py
View file @
91352eec
...
@@ -35,7 +35,6 @@ from Products.ZSQLCatalog.interfaces.search_key import ISearchKey
...
@@ -35,7 +35,6 @@ from Products.ZSQLCatalog.interfaces.search_key import ISearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
import
re
import
re
FULLTEXT_BOOLEAN_DETECTOR
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-<>
\(\
~]|[
\*\
)](
\s|$))'
)
class
FullTextKey
(
SearchKey
):
class
FullTextKey
(
SearchKey
):
"""
"""
...
@@ -43,6 +42,7 @@ class FullTextKey(SearchKey):
...
@@ -43,6 +42,7 @@ class FullTextKey(SearchKey):
"""
"""
default_comparison_operator
=
'match'
default_comparison_operator
=
'match'
get_operator_from_value
=
False
get_operator_from_value
=
False
fulltext_boolean_detector
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-<>
\(\
~]|[
\*\
)](
\s|$))'
)
def
parseSearchText
(
self
,
value
,
is_column
):
def
parseSearchText
(
self
,
value
,
is_column
):
return
parse
(
value
,
is_column
)
return
parse
(
value
,
is_column
)
...
@@ -67,7 +67,7 @@ class FullTextKey(SearchKey):
...
@@ -67,7 +67,7 @@ class FullTextKey(SearchKey):
append
=
new_value_list
.
append
append
=
new_value_list
.
append
for
value
in
operator_value_dict
.
pop
(
'match'
,
[]):
for
value
in
operator_value_dict
.
pop
(
'match'
,
[]):
if
isinstance
(
value
,
basestring
)
and
\
if
isinstance
(
value
,
basestring
)
and
\
FULLTEXT_BOOLEAN_DETECTOR
.
match
(
value
)
is
not
None
:
self
.
fulltext_boolean_detector
.
match
(
value
)
is
not
None
:
operator_value_dict
.
setdefault
(
'match_boolean'
,
[]).
append
(
value
)
operator_value_dict
.
setdefault
(
'match_boolean'
,
[]).
append
(
value
)
else
:
else
:
append
(
value
)
append
(
value
)
...
...
product/ZSQLCatalog/SearchKey/MroongaBooleanFullTextKey.py
0 → 100644
View file @
91352eec
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2014-2006 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
MroongaFullTextKey
import
MroongaFullTextKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
class
MroongaBooleanFullTextKey
(
MroongaFullTextKey
):
"""
This SearchKey generates SQL fulltext comparisons for Mroonga whose
default comparison operator is match_boolean.
"""
default_comparison_operator
=
'match_boolean'
verifyClass
(
ISearchKey
,
MroongaBooleanFullTextKey
)
product/ZSQLCatalog/SearchKey/MroongaFullTextKey.py
0 → 100644
View file @
91352eec
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2014-2006 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
FullTextKey
import
FullTextKey
from
Products.ZSQLCatalog.Query.SimpleQuery
import
SimpleQuery
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
import
re
class
MroongaFullTextKey
(
FullTextKey
):
"""
This SearchKey generates SQL fulltext comparisons for Mroonga.
"""
default_comparison_operator
=
'match'
fulltext_boolean_detector
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-
\("]|[\
*
\)"](\
s|$))
')
def _buildQuery(self, operator_value_dict, logical_operator, parsed, group):
"""
Special Query builder for MroongaFullText queries:
* by default '
AND
' search by using '
*
D
+
' pragma.
* similarity search for non-boolean queries by using '
*
S
"..."' operator.
"""
column = self.getColumn()
query_list = []
append = query_list.append
match_query = operator_value_dict.pop('
match
', [])
match_boolean_query = operator_value_dict.pop('
match_boolean
', [])
fulltext_query = '
*
D
+
'
if match_query:
fulltext_query += '
*
S
"%s"' % '
'.join(x.replace('"', '
\
\
"') for x in match_query)
if match_boolean_query:
fulltext_query += '
%
s
' % '
'.join(match_boolean_query)
append(SimpleQuery(search_key=self,
comparison_operator='
match_boolean
',
group=group, **{column: fulltext_query}))
return query_list
verifyClass(ISearchKey, MroongaFullTextKey)
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