For performance reasons, when fuzzy search was introduces it was decided to limit the number of records used for finding fuzzy terms to 1000. Because of this, when a database contains more than 1000 products matching words that start with the same letter, further products are not examined. This can lead to searches not finding an existing exact match. This commit introduces a fallback mechanism so that, if we are in a situation where the maximum number of examined records was fetched, we also explicitly check for a possible exact match across all records. Steps to reproduce: - Do not install the pg_trgm extension. - Have more than 1000 products containing searchable words (name, description...) starting with the same letter. - Add one more such product (so that it is not in the 1000 first ones). - Search for that last product by correctly typing the word. => Exact match was not returned. task-2870947 closes odoo/odoo#97657 X-original-commit: 6d24ea28b236155d542e3d2be3da379b9f4e9ce6 Signed-off-by: Romain Derie (rde) <rde@odoo.com>
34 lines
973 B
Python
34 lines
973 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class TestModel(models.Model):
|
|
""" Add website option in server actions. """
|
|
|
|
_name = 'test.model'
|
|
_inherit = [
|
|
'website.seo.metadata',
|
|
'website.published.mixin',
|
|
'website.searchable.mixin',
|
|
]
|
|
_description = 'Website Model Test'
|
|
|
|
name = fields.Char(required=1)
|
|
|
|
@api.model
|
|
def _search_get_detail(self, website, order, options):
|
|
return {
|
|
'model': 'test.model',
|
|
'base_domain': [],
|
|
'search_fields': ['name'],
|
|
'fetch_fields': ['name'],
|
|
'mapping': {
|
|
'name': {'name': 'name', 'type': 'text', 'match': True},
|
|
'website_url': {'name': 'name', 'type': 'text', 'truncate': False},
|
|
},
|
|
'icon': 'fa-check-square-o',
|
|
'order': 'name asc, id desc',
|
|
}
|