0

I am trying to implement SOSL list view search and this is sort of follow up question.

I am trying this query in from Apex and getting error in title:

System.debug(
        Search.find('FIND \'foo\' IN ALL FIELDS RETURNING Account(Id, Name USING LISTVIEW=MyNameScpace__foo)')
);

Side question - what is the difference between search.find and search.query?

1

I am trying this query in from Apex and getting error in title:

This query works fine in my org. I suspect you have a typo somewhere in your string. Have you tried writing this as a direct inline query? The compiler should give you more information.

Side question - what is the difference between search.find and search.query?

The former ("find") returns a Search.SearchResults object, which allows you to get Search.SearchResult objects, which includes the "snippet" that shows you the matching text from the record. The latter ("query") returns a normal List<List<SObject>> and does not include the additional WITH SNIPPET information.

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.