You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.0 KiB

  1. #. You can create an index for the `name` field of `res.partner`.
  2. #. In the search you can use:
  3. ``self.env['res.partner'].search([('name', '%', 'Jon Miller)])``
  4. #. In this example the function will return positive result for `John Miller`
  5. or `John Mill`.
  6. #. You can tweak the number of strings to be returned by adjusting the set
  7. limit (default: 0.3). NB: Currently you have to set the limit by executing
  8. the following SQL statement:
  9. ``self.env.cr.execute("SELECT set_limit(0.2);")``
  10. #. Another interesting feature is the use of ``similarity(column, 'text')``
  11. function in the ``order`` parameter to order by similarity. This module just
  12. contains a basic implementation which doesn't perform validations and has to
  13. start with this function. For example you can define the function as
  14. followed:
  15. ``similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table``
  16. For further questions read the Documentation of the
  17. `pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`_ module.