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.

130 lines
4.4 KiB

  1. ============
  2. Fuzzy Search
  3. ============
  4. .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. !! This file is generated by oca-gen-addon-readme !!
  6. !! changes will be overwritten. !!
  7. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
  9. :target: https://odoo-community.org/page/development-status
  10. :alt: Beta
  11. .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
  12. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  13. :alt: License: AGPL-3
  14. .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
  15. :target: https://github.com/OCA/server-tools/tree/11.0/base_search_fuzzy
  16. :alt: OCA/server-tools
  17. .. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
  18. :target: https://runbot.odoo-community.org/runbot/149/11.0
  19. :alt: Try me on Runbot
  20. |badge1| |badge2| |badge3| |badge4|
  21. This addon provides the ability to create GIN or GiST indexes of char and text
  22. fields and also to use the search operator `%` in search domains. Currently
  23. this module doesn't change the backend search or anything else. It provides
  24. only the possibilty to perfrom the fuzzy search for external addons.
  25. **Table of contents**
  26. .. contents::
  27. :local:
  28. Installation
  29. ============
  30. #. The PostgreSQL extension ``pg_trgm`` should be available. In debian based
  31. distribution you have to install the `postgresql-contrib` module.
  32. #. Install the ``pg_trgm`` extension to your database or give your postgresql
  33. user the ``SUPERUSER`` right (this allows the odoo module to install the
  34. extension to the database).
  35. Configuration
  36. =============
  37. If the odoo module is installed:
  38. #. You can define ``GIN`` and ``GiST`` indexes for `char` and `text` via
  39. `Settings -> Database Structure -> Trigram Index`. The index name will
  40. automatically created for new entries.
  41. Usage
  42. =====
  43. #. You can create an index for the `name` field of `res.partner`.
  44. #. In the search you can use:
  45. ``self.env['res.partner'].search([('name', '%', 'Jon Miller)])``
  46. #. In this example the function will return positive result for `John Miller`
  47. or `John Mill`.
  48. #. You can tweak the number of strings to be returned by adjusting the set
  49. limit (default: 0.3). NB: Currently you have to set the limit by executing
  50. the following SQL statment:
  51. ``self.env.cr.execute("SELECT set_limit(0.2);")``
  52. #. Another interesting feature is the use of ``similarity(column, 'text')``
  53. function in the ``order`` parameter to order by similarity. This module just
  54. contains a basic implementation which doesn't perform validations and has to
  55. start with this function. For example you can define the function as
  56. followed:
  57. ``similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table``
  58. For further questions read the Documentation of the
  59. `pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`_ module.
  60. Known issues / Roadmap
  61. ======================
  62. * Modify the general search parts (e.g. in tree view or many2one fields)
  63. * Add better `order by` handling
  64. Bug Tracker
  65. ===========
  66. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
  67. In case of trouble, please check there if your issue has already been reported.
  68. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
  69. Do not contact contributors directly about support or help with technical issues.
  70. Credits
  71. =======
  72. Authors
  73. ~~~~~~~
  74. * bloopark systems GmbH & Co. KG
  75. * Eficent
  76. * Serpent CS
  77. Contributors
  78. ~~~~~~~~~~~~
  79. * Christoph Giesel <https://github.com/christophlsa>
  80. * Jordi Ballester <jordi.ballester@eficent.com>
  81. * Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
  82. * Dave Lasley <dave@laslabs.com>
  83. * Vicent Cubells <vicent.cubells@tecnativa.com>
  84. Maintainers
  85. ~~~~~~~~~~~
  86. This module is maintained by the OCA.
  87. .. image:: https://odoo-community.org/logo.png
  88. :alt: Odoo Community Association
  89. :target: https://odoo-community.org
  90. OCA, or the Odoo Community Association, is a nonprofit organization whose
  91. mission is to support the collaborative development of Odoo features and
  92. promote its widespread use.
  93. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/11.0/base_search_fuzzy>`_ project on GitHub.
  94. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.