This addon provides the ability to create GIN or GiST indexes of char and text fields and also to use the search operator % in search domains. Currently this module doesn't change the backend search or anything else. It provides only the possibilty to perfrom the fuzzy search for external addons.
pg_trgm
should be available. In debian based
distribution you have to install the postgresql-contrib module.pg_trgm
extension to your database or give your postgresql
user the SUPERUSER
right (this allows the odoo module to install the
extension to the database).If the odoo module is installed:
GIN
and GiST
indexes for char and text via
Settings -> Database Structure -> Trigram Index. The index name will
automatically created for new entries.You can create an index for the name field of res.partner.
In the search you can use:
self.env['res.partner'].search([('name', '%', 'Jon Miller)])
In this example the function will return positive result for John Miller or John Mill.
You can tweak the number of strings to be returned by adjusting the set limit (default: 0.3). NB: Currently you have to set the limit by executing the following SQL statment:
self.env.cr.execute("SELECT set_limit(0.2);")
Another interesting feature is the use of similarity(column, 'text')
function in the order
parameter to order by similarity. This module just
contains a basic implementation which doesn't perform validations and has to
start with this function. For example you can define the function as
followed:
similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table
For further questions read the Documentation of the pg_trgm module.
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smash it by providing detailed and welcomed feedback.
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。