-1

I have run this sosl Query in editor,It gives zero records

 FIND {Doc*} IN ALL FIELDS RETURNING Document__c ( Revision__c,name,Release_Date__c,Part__c,Part__r.name,PartValueSOSL__c,PlatformSOSL__c,Release_Date_value__c,AircraftManufacturerSOSL__c,Content_Document_Ids__c,RecordType.Name WHERE AircraftManufacturerSOSL__c = 'Airbus'  and  recordtype.id in ( '012m00000008oqCAAQ','012m00000008r6MAAQ','012m00000008opnAAA','012m00000008oq7AAA','012m00000008scdAAA','012m00000008oq2AAA','012m00000008opsAAA','012m00000008opxAAA','012m00000008r6HAAQ')  )

By testing purpose I just ran same query using "soql":

   select Revision__c,name,Release_Date__c,Part__c,Part__r.name,PartValueSOSL__c,PlatformSOSL__c,Release_Date_value__c,AircraftManufacturerSOSL__c,Content_Document_Ids__c,RecordType.Name WHERE AircraftManufacturerSOSL__c = 'Airbus'  and  recordtype.id in ( '012m00000008oqCAAQ','012m00000008r6MAAQ','012m00000008opnAAA','012m00000008oq7AAA','012m00000008scdAAA','012m00000008oq2AAA','012m00000008opsAAA','012m00000008opxAAA','012m00000008r6HAAQ')  )

Above soql query gives 4 records.

Here DOC * represents search text.

my question is: Why soql and sosl gives different result in case

What changes I have to make for search text to get "4 records"

I have tried like this

    Doc-*, *doc* 

seems like I dont have any field with "doc". So i have decide to change the sosl query without using search text. Is it possible? or any other solutions?

3

SOSL searches based on the search term. Here doc will be your search text and it is not the field name on which it will be searching.

Use SOSL when you don’t know which object or field the data resides in, and you want to:

  • Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize multiple terms within a field and build a search index from this, SOSL searches are faster and can return more relevant results.
  • Retrieve multiple objects and fields efficiently where the objects might or might not be related to one another.
  • Retrieve data for a particular division in an organization using the divisions feature.

I prefer using SOSL, when I need to search in LongTextArea or RichTextArea where SOQL query doesn't support those in WHERE clause for filtering.

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.