0

I am writing a text search query with SOSL to match exact phrase. But it's giving results like in a wildcard search.

FIND {CCMS} IN NAME FIELDS RETURNING Account(Id, Name)

Results :

  • 001xxxxxxxxxx CCMSI
  • 001xxxxxxxxxx CCMSI
  • 001xxxxxxxxxx CCMSI

Result set is same for CMSI, CCMS* as well.

When I don't use wildcard, I expect the exact text to be matched and returned results. Isn't it the way SOSL works? I noted few related questions in the forum but this behavior is still confused.

1 Answer 1

2

SOSL does exact match of the word by default. The results you got is the expected behavior of SOSL. It checked for the CCMS but it isn't full word matching as you want it to be.

The workaround I can think of is

  • let SOSL return all the results then iterate over those results and compare the value that you want to search against a particular field
  • OR if possible you can switch to SOQL and use exact full word match if it can solve your purpose.
2
  • So what would be the difference between {CCMS} and {CCMS*} ?
    – highfive
    Commented Dec 8, 2016 at 10:51
  • I think the first sentence you mean does not exact match is it?
    – highfive
    Commented Dec 9, 2016 at 6:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .