2

I am Running into something that appears to be a bug in how Salesforce SOSL queries work with knowledge.

Consider this Snippet of code:

String searchquery = 'FIND \'SEARCH TERM\' IN ALL FIELDS RETURNING Article__kav(Title, Summary, UrlName, LastPublishedDate, LastModifiedById WHERE PublishStatus =\'Online\' AND Language = \'en_US\'' + 
                     'AND Not_Searchable__c = false OFFSET 0) WITH DATA CATEGORY DataCat__c BELOW DataKitten__c ';
System.debug(search.query(searchquery));

Then this Snippet of code:

String searchquery = 'FIND \'SEARCH TERM\' IN ALL FIELDS RETURNING Article__kav(Title, Summary, UrlName, LastPublishedDate, LastModifiedById WHERE PublishStatus =\'Online\' AND Language = \'en_US\'' + 
                     'AND Not_Searchable__c = false) WITH DATA CATEGORY DataCat__c BELOW DataKitten__c ';
System.debug(search.query(searchquery));

Now the only difference between the two queries is OFFSET 0, yet I am getting a completely different order. The relevance of the search seems to be completely disregarded the second I add OFFSET to the query.

Now what's even stranger is doing the query in the developer console:

Without Offset:

FIND {SEARCH TERM} IN ALL FIELDS RETURNING Article__kav(Title, Summary, UrlName, LastPublishedDate, LastModifiedById WHERE PublishStatus ='Online' AND Language = 'en_US' AND Not_Searchable__c = false) WITH DATA CATEGORY DataCat__c BELOW DataKitten__c

With Offset:

FIND {SEARCH TERM} IN ALL FIELDS RETURNING Article__kav(Title, Summary, UrlName, LastPublishedDate, LastModifiedById WHERE PublishStatus ='Online' AND Language = 'en_US' AND Not_Searchable__c = false OFFSET 0) WITH DATA CATEGORY DataCat__c BELOW DataKitten__c 

The developer console showing the same order with and without the offset. Anyone have any idea what is happening on this?

UPDATE

It appears to be adding an Order By ID when Offset is included.. but that still does not explain why this is happening.

To further clarify the SOSL_EXECUTE_BEGIN in debug log does not show the Order By ID when it is executing the SOSL search. It's just returning the results in such a way.

4
  • Did you try to define any specific order?
    – o-lexi
    Commented Mar 7, 2017 at 20:58
  • @Oleksiy Well the order I need is relevance is there any way to specify to Order By using that? From what I gathered reading the documentation if you want that you simply don't put in an Order By.
    – Halfwarr
    Commented Mar 7, 2017 at 21:02
  • What's the purpose of using offset, here?
    – sfdcfox
    Commented Mar 7, 2017 at 21:06
  • @sfdcfox we were using it for pagination
    – Halfwarr
    Commented Mar 7, 2017 at 21:16

1 Answer 1

0

So after logging a case with Salesforce. I got a response back from their R&D team, that it is indeed a bug. They have no idea how long before a fix will be implemented.

Here is the Known Issue created for it.

0

You must log in to answer this question.

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