Skip to main content

Fuzzy search with the PostgreSQL trigram extension

Project description

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

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 possibility to perform the fuzzy search for external addons.

Table of contents

Installation

  1. The PostgreSQL extension pg_trgm should be available. In debian based distribution you have to install the postgresql-contrib module.

  2. Install the 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).

Configuration

If the odoo module is installed:

  1. You can define GIN and GiST indexes for char and text via Settings -> Database Structure -> Trigram Index. The index name will automatically created for new entries.

Usage

  1. You can create an index for the name field of res.partner.

  2. In the search you can use:

    self.env['res.partner'].search([('name', '%', 'Jon Miller)])

  3. In this example the function will return positive result for John Miller or John Mill.

  4. 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 statement:

    self.env.cr.execute("SELECT set_limit(0.2);")

For further questions read the Documentation of the pg_trgm module.

Usage with demo data

There are some demo data that allow you to test functionally this module if you are in a demo database. The steps are the following:

  1. Go to Contacts and type the text Jon Smith or Smith John in the search box and select Search Display Name for: …

  2. You will see two contacts, and they are the ones with display names John Smith and John Smizz.

Known issues / Roadmap

Bug Tracker

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 to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • bloopark systems GmbH & Co. KG

  • ForgeFlow

  • Serpent CS

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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.

This module is part of the OCA/server-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo_addon_base_search_fuzzy-16.0.1.0.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_addon_base_search_fuzzy-16.0.1.0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5e3787395a8825bc5f4a28db677354c3ff5febe9e91731477cd5e8b6ad7410
MD5 d98bcefb40acd51cabd4e92dee216da3
BLAKE2b-256 56d4aed04ac8b6712f0ca42f09014e23a9131d3040a45e9d89c87cca08366c1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page