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.

107 lines
3.4 KiB

8 years ago
  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. =========================
  5. PostgreSQL Trigram Search
  6. =========================
  7. This addon provides the ability to create GIN or GiST indexes of char and text
  8. fields and also to use the search operator `%` in search domains. Currently
  9. this module doesn't change the backend search or anything else. It provides
  10. only the possibilty to perfrom the fuzzy search for external addons.
  11. Installation
  12. ============
  13. #. The PostgreSQL extension ``pg_trgm`` should be available. In debian based
  14. distribution you have to install the `postgresql-contrib` module.
  15. #. Install the ``pg_trgm`` extension to your database or give your postgresql
  16. user the ``SUPERUSER`` right (this allows the odoo module to install the
  17. extension to the database).
  18. Configuration
  19. =============
  20. If the odoo module is installed:
  21. #. You can define ``GIN`` and ``GiST`` indexes for `char` and `text` via
  22. `Settings -> Database Structure -> Trigram Index`. The index name will
  23. automatically created for new entries.
  24. Usage
  25. =====
  26. #. You can create an index for the `name` field of `res.partner`.
  27. #. In the search you can use:
  28. ``self.env['res.partner'].search([('name', '%', 'Jon Miller)])``
  29. #. In this example the function will return positive result for `John Miller` or
  30. `John Mill`.
  31. #. You can tweak the number of strings to be returned by adjusting the set limit
  32. (default: 0.3). NB: Currently you have to set the limit by executing the
  33. following SQL statment:
  34. ``self.env.cr.execute("SELECT set_limit(0.2);")``
  35. #. Another interesting feature is the use of ``similarity(column, 'text')``
  36. function in the ``order`` parameter to order by similarity. This module just
  37. contains a basic implementation which doesn't perform validations and has to
  38. start with this function. For example you can define the function as
  39. followed:
  40. ``similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table``
  41. For further questions read the Documentation of the
  42. `pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`_ module.
  43. Known issues / Roadmap
  44. ======================
  45. * Modify the general search parts (e.g. in tree view or many2one fields)
  46. * add better `order by` handling
  47. Bug Tracker
  48. ===========
  49. Bugs are tracked on `GitHub Issues
  50. <https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
  51. check there if your issue has already been reported. If you spotted it first,
  52. help us smash it by providing detailed and welcomed feedback.
  53. Credits
  54. =======
  55. Images
  56. ------
  57. * Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
  58. Contributors
  59. ------------
  60. * Christoph Giesel <https://github.com/christophlsa>
  61. * Jordi Ballester <jordi.ballester@eficent.com>
  62. * Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
  63. * Dave Lasley <dave@laslabs.com>
  64. Maintainer
  65. ----------
  66. .. image:: https://odoo-community.org/logo.png
  67. :alt: Odoo Community Association
  68. :target: https://odoo-community.org
  69. This module is maintained by the OCA.
  70. OCA, or the Odoo Community Association, is a nonprofit organization whose
  71. mission is to support the collaborative development of Odoo features and
  72. promote its widespread use.
  73. To contribute to this module, please visit https://odoo-community.org.