I seem to have an odd issue where for certain text phrases being searched with sosl, not all events being queried with the sosl search are returned that should be.
For example: when FIND (meeting*) IN ALL FIELDS RETURNING Event(Id, Subject) there are events with meeting blatantly in the subject that are not coming back from the query...
For example, there is one titled 'Weekly Staff Meeting' that does not returned, also some title 'Test Meeting' that don't get returned, while one titled 'Test Meeting' does (although the Test Meeting that returns has another text field with Meeting Room X in it while the others do not have 'meeting' mentioned outside the subject).
I dynamically build the sosl search terms:
//Add wildcards to the sosl and soql search queries for the free text search if anything was entered into that filter
List<String> searchList = description.split(',');
//system.debug(searchList);
String soslSearch = '';
String soqlSearch = '';
Set<String>soqlSet = new Set<String>();
for(Integer i = 0; i < searchList.size(); i++){
soslSearch += '('+searchList[i]+'*) ';
soqlSet.add('%'+searchList[i]+'%');
if(i < searchList.size() - 1){
soslSearch += 'OR ';
}
}
Where description is a comma separated list of search keywords like 'meeting,hello,goodbye' etc... So the sosl search part will be (meeting*) OR (hello*) OR (goodbye*).
Then do:
String soslQuery = 'Find :soslSearch IN ALL FIELDS RETURNING Event(Id, Subject, StartDateTime)';
//system.debug('If Search Filter Text And There Are Users(sosl): '+soslQuery);
//List<List<Event>> searchListDescription = search.query(soslQuery);
List<List<Event>> searchListDescription = withoutSharingClass.soslQueryEvents(soslQuery);
I cannot see what is incorrect about the sosl setup, or why it is doing this. Going into the effected orgs dev console and directly querying, it doesn't return all the events either. So it may perhaps not be the query but something with permissions... but wanted to see if anyone finds any issue with my query that could be causing it.
Without the text searches, I do soql queries that return everything just fine.