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.

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