|
| 1 | +============ |
| 2 | +Fuzzy Search |
| 3 | +============ |
| 4 | + |
| 5 | +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 6 | + !! This file is generated by oca-gen-addon-readme !! |
| 7 | + !! changes will be overwritten. !! |
| 8 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 9 | +
|
| 10 | +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png |
| 11 | + :target: https://odoo-community.org/page/development-status |
| 12 | + :alt: Beta |
| 13 | +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png |
| 14 | + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
| 15 | + :alt: License: AGPL-3 |
| 16 | +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github |
| 17 | + :target: https://github.com/OCA/server-tools/tree/13.0/base_search_fuzzy |
| 18 | + :alt: OCA/server-tools |
| 19 | +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
| 20 | + :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_search_fuzzy |
| 21 | + :alt: Translate me on Weblate |
| 22 | +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png |
| 23 | + :target: https://runbot.odoo-community.org/runbot/149/13.0 |
| 24 | + :alt: Try me on Runbot |
| 25 | + |
| 26 | +|badge1| |badge2| |badge3| |badge4| |badge5| |
| 27 | + |
| 28 | +This addon provides the ability to create GIN or GiST indexes of char and text |
| 29 | +fields and also to use the search operator `%` in search domains. Currently |
| 30 | +this module doesn't change the backend search or anything else. It provides |
| 31 | +only the possibility to perform the fuzzy search for external addons. |
| 32 | + |
| 33 | +**Table of contents** |
| 34 | + |
| 35 | +.. contents:: |
| 36 | + :local: |
| 37 | + |
| 38 | +Installation |
| 39 | +============ |
| 40 | + |
| 41 | +#. The PostgreSQL extension ``pg_trgm`` should be available. In debian based |
| 42 | + distribution you have to install the `postgresql-contrib` module. |
| 43 | +#. Install the ``pg_trgm`` extension to your database or give your postgresql |
| 44 | + user the ``SUPERUSER`` right (this allows the odoo module to install the |
| 45 | + extension to the database). |
| 46 | + |
| 47 | +Configuration |
| 48 | +============= |
| 49 | + |
| 50 | +If the odoo module is installed: |
| 51 | + |
| 52 | +#. You can define ``GIN`` and ``GiST`` indexes for `char` and `text` via |
| 53 | + `Settings -> Database Structure -> Trigram Index`. The index name will |
| 54 | + automatically created for new entries. |
| 55 | + |
| 56 | +Usage |
| 57 | +===== |
| 58 | + |
| 59 | +#. You can create an index for the `name` field of `res.partner`. |
| 60 | +#. In the search you can use: |
| 61 | + |
| 62 | + ``self.env['res.partner'].search([('name', '%', 'Jon Miller)])`` |
| 63 | + |
| 64 | +#. In this example the function will return positive result for `John Miller` |
| 65 | + or `John Mill`. |
| 66 | + |
| 67 | +#. You can tweak the number of strings to be returned by adjusting the set |
| 68 | + limit (default: 0.3). NB: Currently you have to set the limit by executing |
| 69 | + the following SQL statement: |
| 70 | + |
| 71 | + ``self.env.cr.execute("SELECT set_limit(0.2);")`` |
| 72 | + |
| 73 | +#. Another interesting feature is the use of ``similarity(column, 'text')`` |
| 74 | + function in the ``order`` parameter to order by similarity. This module just |
| 75 | + contains a basic implementation which doesn't perform validations and has to |
| 76 | + start with this function. For example you can define the function as |
| 77 | + followed: |
| 78 | + |
| 79 | + ``similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table`` |
| 80 | + |
| 81 | +For further questions read the Documentation of the |
| 82 | +`pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`_ module. |
| 83 | + |
| 84 | + |
| 85 | +Usage with demo data |
| 86 | +==================== |
| 87 | + |
| 88 | +There are some demo data that allow you to test functionally this module |
| 89 | +if you are in a **demo** database. The steps are the following: |
| 90 | + |
| 91 | +#. Go to *Contacts* and type the text **Jon Smith** or **Smith John** in |
| 92 | + the search box and select **Search Display Name for: ...** |
| 93 | +#. You will see two contacts, and they are the ones with display names |
| 94 | + **John Smith** and **John Smizz**. |
| 95 | + |
| 96 | +Known issues / Roadmap |
| 97 | +====================== |
| 98 | + |
| 99 | +* Modify the general search parts (e.g. in tree view or many2one fields) |
| 100 | +* Add better `order by` handling |
| 101 | + |
| 102 | +Bug Tracker |
| 103 | +=========== |
| 104 | + |
| 105 | +Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. |
| 106 | +In case of trouble, please check there if your issue has already been reported. |
| 107 | +If you spotted it first, help us smashing it by providing a detailed and welcomed |
| 108 | +`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_search_fuzzy%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
| 109 | + |
| 110 | +Do not contact contributors directly about support or help with technical issues. |
| 111 | + |
| 112 | +Credits |
| 113 | +======= |
| 114 | + |
| 115 | +Authors |
| 116 | +~~~~~~~ |
| 117 | + |
| 118 | +* bloopark systems GmbH & Co. KG |
| 119 | +* Eficent |
| 120 | +* Serpent CS |
| 121 | + |
| 122 | +Contributors |
| 123 | +~~~~~~~~~~~~ |
| 124 | + |
| 125 | +* Christoph Giesel <https://github.com/christophlsa> |
| 126 | +* Jordi Ballester < [email protected]> |
| 127 | +* Serpent Consulting Services Pvt. Ltd. < [email protected]> |
| 128 | + |
| 129 | + |
| 130 | +* `Tecnativa <https://www.tecnativa.com>`_: |
| 131 | + |
| 132 | + * Vicent Cubells |
| 133 | + * Ernesto Tejeda |
| 134 | + |
| 135 | +Maintainers |
| 136 | +~~~~~~~~~~~ |
| 137 | + |
| 138 | +This module is maintained by the OCA. |
| 139 | + |
| 140 | +.. image:: https://odoo-community.org/logo.png |
| 141 | + :alt: Odoo Community Association |
| 142 | + :target: https://odoo-community.org |
| 143 | + |
| 144 | +OCA, or the Odoo Community Association, is a nonprofit organization whose |
| 145 | +mission is to support the collaborative development of Odoo features and |
| 146 | +promote its widespread use. |
| 147 | + |
| 148 | +This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_search_fuzzy>`_ project on GitHub. |
| 149 | + |
| 150 | +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
0 commit comments