OdooWiki OCA HUB

Fuzzy Search

base_search_fuzzy folder_open OCA/server-tools open_in_new
Uncategorized License: AGPL-3

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.

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Lets administrators create PostgreSQL trigram indexes on text or character fields so that other addons can perform fuzzy (approximate) searches, and registers the '%' fuzzy search operator in search domains.

This module is a technical foundation for fuzzy searching. It does not change how Odoo searches by itself; it prepares the database so that approximate text matching becomes possible.

Where it appears in Odoo: - A new "Trigram Index" screen (list and form) is available under the technical settings area, restricted to technical users. - On that screen you pick a field (only text or character fields are offered), choose an index type (GIN or GiST) and, for translatable fields, a language.

What happens automatically: - When you save a new index entry, the module builds the index name for you (based on field name and index type) and creates the index in the database. If an index with that name already exists on the same table it is reused; otherwise a number is appended. - Deleting an index entry drops the corresponding database index. - On installation it checks whether the PostgreSQL trigram extension is available and, if the database user is a superuser, installs it automatically; otherwise it only logs a warning. - It registers the '%' operator so that search domains can use fuzzy matching on text fields.

Access rules: everyone can read index entries, but only technical users can create, edit or delete them.

The demo data adds a few contacts and a fuzzy search field on the contact search view for testing.

Depends on

base

Menus it adds

trgm_index_menu
Models and fields (1)
  • trgm.index · new modellang (Language), field_id, index_name, index_type

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 8 confirmed, 1 with no information of 9 versions.

Sources · Odoo 18.0

Confirmed on 2026-11-03 in branch 18.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 19.0
  • The PostgreSQL extension pg_trgm should be available. In debian based distribution you have to install the postgresql-contrib module.
  • 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).

If the odoo module is installed:

  • 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.
  • 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 Smit')])
  • In this example the function will return positive result for John Smith or John Smit.
  • 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:

  • Go to Contacts and type the text Jon Smith or Smith John in the search box and select Search Display Name for: ...
  • You will see two contacts, and they are the ones with display names John Smith and John Smizz.
info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.