Commit Graph
6 Commits
Author SHA1 Message Date
Carlos ValverdeandBenoit Socias 0c8484652e [IMP] website: make fuzzy test more robust
New data will be introduced that involve the "product" word... while
this is a word a fuzzy test is based on. This commit adapts the test so
that its results are based on words that are less likely to appear in
default data.

task-2406626

Part-of: odoo/odoo#67913
Co-authored-by: Benoit Socias <bso@odoo.com>
2023-05-12 19:54:08 +02:00
Benoit Socias e9ea0692bb [FIX] website: not split fuzzy matching candidates on hyphen
Since [1] when the fuzzy search was introduced, the candidate words used
for the fuzzy matching were split on non-'\w' (all non alphanumeric
characters + underscore).

This commit adds '-' (hyphen) to the list of characters that should be
considered part of the same word.

Steps to reproduce:
- Specify a product with name 'micro-vis'
- search for 'micro-vis' or 'microvis'
=> Was not returning any match
=> Now returns fuzzy match even for 'micro-vs'

opw-2801704

[1]: https://github.com/odoo/odoo/commit/c6ba756e4b4704089d02434871788a82d90cb195

closes odoo/odoo#88591

X-original-commit: 10d54d3c6ba46afa86abac5275a02c4b5ec7d5a1
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-04-13 11:55:37 +02:00
Benoit Socias 07290bfe8d [FIX] website: disable fuzzy search if search term contains numbers
Since [1] when fuzzy search was introduced, fuzzy search was also used
when the search term contained numbers.
This is a problem for companies where the shop search is used on
references: the fuzzy search does not match against the whole database
and therefore the exact match might not be found.

After this commit the exact search is used whenever the search term is
made of 80% of numbers or more - because it is very likely to be a
reference or an identifier.

[1]: https://github.com/odoo/odoo/commit/7559626c54e34b41e1549e28276a650accec6986

opw-2715647

closes odoo/odoo#84943

X-original-commit: 7b44907c322a7b78ef4a5cb46627df4f72b21240
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-02-18 21:04:54 +00:00
Thibault Libioulle ecd08f519f [FIX] website: fix matching of search term and fuzzy term
Prior to this commit, when a user searches with an upper case search
term of more than 3 characters, the search was considered as a fuzzy
search even if the result was an exact match.

Since the search is always lowered when there are more than 3
characters, the search is considered as fuzzy only when the search and
fuzzy term are case insensitively distinct.

closes odoo/odoo#84593

X-original-commit: 34362a7c07a2868103b24d16a83a97356ad1f60d
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-02-14 22:31:11 +00:00
Benoit Socias a676344ecc [FIX] website{_*}: not truncate URLs in search results
website{_*}: website, website_blog, website_event, website_forum,
website_sale, website_slides

Since the generic search bar was introduced in [1] all text fields were
truncated in search results.
This caused problems for long URLs which were truncated as well, and
therefore could become invalid.

After this commit URL fields specify `'truncate': False` in their search
detail metadata, which informs the rendering to skip the text truncation
step for that field.
Also added previously missing controller-level tests of the
autocompletion.

Steps to reproduce:
- start odoo with website_forum and demo data
- go to the Help forum
- search for "configure" in the Help forum
- click on the auto-complete suggestion
- => redirected to a 404 page because the URL was shortened
To test the fix on other models, use a long enough name that causes the
problem. E.g.: "This product has such a long name its URL would have
been truncated without the fix contained in this branch".
Note that the problem did not occur on blogs because the URL does not
contain the name, but the same fix was applied for consistency.

[1]: https://github.com/odoo/odoo/commit/7559626c54e34b41e1549e28276a650accec6986

task-2727788

closes odoo/odoo#82621

X-original-commit: 045f741be35e62f5e3a636490c6c1d475b5d78eb
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-01-12 14:55:03 +00:00
Benoit Socias c6ba756e4b [IMP] core, website: use fuzzy matching in web-based search
Before this commit searched terms were the ones entered by the end-user.

After this commit if the searched term is not found then the search is
performed on a resembling term.
The similarity is obtained from a Levenshtein distance combined with
ratios of common and different letters.
By default the dictionary against which the search term is matched is
based on the content of the search fields containing a word that starts
with the first letter of the search term.
If the `pg_trgm` Postgresql extension is installed the dictionary is
built from matches using the `<%%` operator (similar to the
`word_similarity` function).
Several approaches were benchmarked during development, those results
are available through the task record.

task-2379555
https://github.com/odoo/odoo/pull/65871

Part-of: odoo/odoo#65871
2021-09-03 06:59:33 +00:00