# Searching with partial words in a Text field doesn't work anymore

**URL:** <https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545>\
**Category:** User\
**Created:** [September 20, 2022, 9:58am UTC](https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545 "2022-09-20T09:58:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [September 20, 2022, 9:58am UTC](https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545/1 "2022-09-20T09:58:18Z")

</div>

I walked into a strange behavior when doing a search on a `Text` field. Searching for a partial word isn’t working anymore? For example I added the `description` (which is a `Text` field) back on `sale.line` into the tree view and added a new menu item to show all the `sale.line`s. Then do a search like `description: condit` and expected that all the records which have that partial in the text will show up. But it doesn’t, I have to search for the full word like `airconditioner`.

This showed up after migrating from 5.4 to 6.4 and looking at the SQL and documentation there is now a sort of full-text search? But is the above the right behavior? If so, that means that I have to disable full-text search on the field.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [September 20, 2022, 10:26am UTC](https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545/2 "2022-09-20T10:26:26Z")

</div>

Since 6.0, Text fields are by default searched using [Full Text Search](https://www.postgresql.org/docs/current/textsearch.html) for query of the form `(<field>, 'ilike', '%<value>%')`.  
This can be disabled by setting the field attribute [`search_full_text`](https://docs.tryton.org/projects/server/en/latest/ref/fields.html#trytond.model.fields.Text.search_full_text) to `False`.

Normally full text search is more powerful because they have linguistic support (and not regular expression) and they can be indexed.  
We use the `websearch_to_tsquery` syntax in Tryton which is mainly the same feature as web search engine.

In your example you must now type full word to have a match but it will match more variant of the word.

Now with [Left strip wildcard for search code only for full text operand (#11682) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue11682) using double `%%` will disable the full text search and fallback to regexp.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [September 20, 2022, 11:38am UTC](https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545/3 "2022-09-20T11:38:44Z")

</div>

Thanks for the thorough explanation!

> [@ced](#):
>
> In your example you must now type full word to have a match but it will match more variant of the word.

That’s indeed how it works now. In this case the user just enters a partial and press `<enter>` to see the results. And they expected the same result as in 5.4. Also sometimes they search for something where they not know the complete word (was it airconditioner or conditioner?). So they type in the partial. And of course, users are lazy 🤫

> [@ced](#):
>
> Now with [Issue 11682: Left strip wildcard for search code only for full text operand - Tryton issue tracker](https://bugs.tryton.org/issue11682) using double `%%` will disable the full text search and fallback to regexp.

Looking at the issue, this wouldn’t be backported so I have to disable the full-text search for now and prepare for the double `%% ` when the next version comes around so users can decide themselves what to use.

---

<div class="post-metadata">

**Author:** ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)\
**Post date:** [October 20, 2022, 11:39am UTC](https://discuss.tryton.org/t/searching-with-partial-words-in-a-text-field-doesnt-work-anymore/5545/4 "2022-10-20T11:39:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
