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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
4da4f230
Commit
4da4f230
authored
Apr 06, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_search_rank_catalog: only check related document with a rank != 0
parent
845d165d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
bt5/erp5_search_rank_catalog/SkinTemplateItem/portal_skins/erp5_search_rank/Base_calculateSearchRank.py
...portal_skins/erp5_search_rank/Base_calculateSearchRank.py
+3
-0
bt5/erp5_search_rank_catalog/TestTemplateItem/portal_components/test.erp5.testSearchRank.py
...emplateItem/portal_components/test.erp5.testSearchRank.py
+25
-1
No files found.
bt5/erp5_search_rank_catalog/SkinTemplateItem/portal_skins/erp5_search_rank/Base_calculateSearchRank.py
View file @
4da4f230
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
NegatedQuery
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
portal_catalog
=
portal
.
portal_catalog
# PR(B) = (1-d) + d x ( PR(A1) / N(A1) + ... + PR(An) / N(An) )
# PR(B) = (1-d) + d x ( PR(A1) / N(A1) + ... + PR(An) / N(An) )
...
@@ -16,6 +18,7 @@ rank = 0
...
@@ -16,6 +18,7 @@ rank = 0
# Search all document linking to the context
# Search all document linking to the context
for
sql_result
in
portal_catalog
(
for
sql_result
in
portal_catalog
(
select_list
=
[
'search_rank'
],
select_list
=
[
'search_rank'
],
search_rank
=
NegatedQuery
(
SimpleQuery
(
search_rank
=
0
)),
**
{
'category.category_uid'
:
context
.
getUid
()}
**
{
'category.category_uid'
:
context
.
getUid
()}
):
):
# In case of acquired category, it is not explicitely defined on the document
# In case of acquired category, it is not explicitely defined on the document
...
...
bt5/erp5_search_rank_catalog/TestTemplateItem/portal_components/test.erp5.testSearchRank.py
View file @
4da4f230
...
@@ -83,13 +83,37 @@ class TestSearchRank(ERP5TypeTestCase):
...
@@ -83,13 +83,37 @@ class TestSearchRank(ERP5TypeTestCase):
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
# Linked from one document only with no score
linked_document_1
.
setFooCategoryValue
(
document
)
linked_document_1
.
Base_zUpdateSearchRank
(
uid
=
linked_document_1
.
getUid
(),
search_rank
=
0
)
self
.
tic
()
document
.
Base_updateSearchRank
()
self
.
assertIndexedDocumentSearchRankEqual
(
document
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'0'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
# Linked from one document only with a lower score
linked_document_1
.
setFooCategoryValue
(
document
)
linked_document_1
.
Base_zUpdateSearchRank
(
uid
=
linked_document_1
.
getUid
(),
search_rank
=
100
)
self
.
tic
()
document
.
Base_updateSearchRank
()
self
.
assertIndexedDocumentSearchRankEqual
(
document
,
'15085'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'100'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
# Linked from 2 documents (rank is higher than one doc only)
# Linked from 2 documents (rank is higher than one doc only)
linked_document_1
.
setFooCategoryValue
(
document
)
linked_document_1
.
setFooCategoryValue
(
document
)
linked_document_2
.
setFooCategoryValue
(
document
)
linked_document_2
.
setFooCategoryValue
(
document
)
self
.
tic
()
self
.
tic
()
document
.
Base_updateSearchRank
()
linked_document_1
.
Base_updateSearchRank
()
linked_document_1
.
Base_updateSearchRank
()
linked_document_2
.
Base_updateSearchRank
()
linked_document_2
.
Base_updateSearchRank
()
document
.
Base_updateSearchRank
()
self
.
assertIndexedDocumentSearchRankEqual
(
document
,
'40500'
)
self
.
assertIndexedDocumentSearchRankEqual
(
document
,
'40500'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_1
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
self
.
assertIndexedDocumentSearchRankEqual
(
linked_document_2
,
'15000'
)
...
...
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