1

I was wondering if there is a way for me to search for a non-accented value in SOQL and the results would bring me words with and without accent.

Example: I searched for "helló" and the result brings me records that have "helló" and "hello". Or i I searched for "hello" and the result brings me records that have "helló" and "hello".

Note: I know that in SOSL this search works, but in addition to what I requested, I also need to search for words that contain my searched string. And that the SOSL "FIND" does not. It only searches words that START with the searched value.

Then I could search: "hello" and the result would also bring me words like "thishello" "testhello" or "thishelló" "testhelló"....

Thanks.

1

Unlike SOSL, SOQL doesn't support accented character mapping, whilst SOSL cannot perform search term matching within words (only at the start). The work falls to you, as the developer, to bridge the gaps.

An option you could use is to analyse the string (iterate the entered value) to find all characters outside the ASCII character ranges and replace them in the value passed to SOQL using "_" (a single character wildcard when used with LIKE). This will (in all probability) return many false positive match results. However, you can build in generation of "filter" regular expressions to your code that can weed out the false positives from the results you got back.

This question includes how to map characters with diacritics to ASCII characters. This could be the basis for building the filters so you can generate regex matches like:

hell[oó]

when filtering the results of your LIKE-based SOQL query.

0

A possible workaround could be to create custom fields and automatically fill them in with the same text, but without accents. And then standartize the input and use SOQL query filtered on that custom field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.