Questions tagged [dynamic-sosl]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
44 views

SOSL Search with two terms from Search.query

I'm running a SOSL query in my Apex code using Search.query. My existing query with one term already works. This String queryString = 'FIND \'' + guid + '\' IN ALL FIELDS RETURNING Opportunity(...
James's user avatar
  • 319
0 votes
1 answer
42 views

Run SOSL without any search term

I have read the documentation for SOSL and have a usecase which is not explicitly mentioned anywhere. I can not use SOQL as it takes over 15 seconds. We have some non-index fields and wild cards ...
Dave's user avatar
  • 1
0 votes
0 answers
31 views

How are snippets generated when searching Knowledge Articles with SOSL and including the WITH SNIPPET keyword?

My user has admin profile and I made sure that I have at least read access on all fields on Knowledge__kav object. When I execute the below query in Developer Console I often do not get any snippets ...
smukov's user avatar
  • 5,503
0 votes
1 answer
77 views

How to add wildcard to SOSL variable binding

I am doing a LWC search component that is handled by a SOSL query. Currently i am sending the searchTerm and creating a dynamic SOSL query that is executed by Search.query(queryString) method. In the ...
kmavrov's user avatar
0 votes
1 answer
70 views

Unpredictable behavior while escaping special characters in sosl

According to SOSL reference here ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + - are reserved characters and need to be escaped by \ I have a rather simple dynamic SOSL Query for searching inside ...
Aman Sharma's user avatar
0 votes
1 answer
226 views

How to use WHERE clause in SOSL query

I am trying to use the existing LWC with some modifications to get records on the basis of RecordType.Id but it's throwing an error instead. System.QueryException: expecting a right parentheses, found ...
user avatar
0 votes
0 answers
132 views

Need help in putting not equal to field in SOSL in Salesforce

I have created the below SOSL for my Apex class as per the req to return the queried valued from the data base , but i am not able to put the not equal to operator in below SOSL, i have tried the ...
Sumintha's user avatar
0 votes
2 answers
2k views

Script-thrown exception in salesforce Apex

Hi I am trying to make a dynamic SOSL on the basis of certain condition, but getting the error as script thrown exception. below is my code : List<List<ABC__c>> list1 = new List<List<...
Taniya k's user avatar
0 votes
0 answers
174 views

SOSL does not find gmail domain in emails for Site Guest User

When running a SOSL query as the Site Guest User in an Experience Site, I am unable to retrieve any results if I return more than one object at a time while the search query is 'gmail.com' As an ...
nuadaria's user avatar
2 votes
1 answer
98 views

Why does SOQL show there is data but SOSL returns no results?

I want to search for a list of phrases. I used SOSL to search for a string to begin with but it is returning zero results yet when I run a soql I can see there is data. Any ideas? Thanks. FIND {Animal}...
Pauline's user avatar
  • 353
1 vote
0 answers
340 views

Dynamic SOSL with multiple search terms not returning records with email or phone number

I am facing couple of challenges with Dynamic SOSL. Records are available with "[email protected] or [email protected]" and "(123) 456-7890"(based on locale). we are using ...
Ragavendra's user avatar
0 votes
1 answer
254 views

SOSL Query: Getting different number of records while searching with 1234* and abcd1234*

I have a community page. It has a search box and a list view to display the search result. Below is the Query I'm building: (It will search in 15M total records) List<List<sObject>> ...
Nitin Shukla's user avatar
1 vote
1 answer
598 views

SOSL query getting malformed query exception

I have built up a dynamic search query using sosl The query string given below FIND {a016g00000D57xKAAR} IN ALL FIELDS RETURNING Attachment(ParentId), ContentVersion(FirstPublishLocationId), ...
Madhurima's user avatar
  • 1,235
1 vote
1 answer
737 views

Not able to search fields using SOSL for Case module

I am trying to fire a SOSL query in Apex to find phone number exits in Case module. Below is the example of one of the cases that I am trying to search. I am using following query to search the ...
Hunt's user avatar
  • 225
2 votes
1 answer
414 views

Variable in SOSL Query

In SOSL can I add a variable to the fields? As: FIND {Clinica} IN Name Fields RETURNING Account(VARIABLE HERE) Thanks
Diego Edargo Pessoa's user avatar
0 votes
1 answer
136 views

SOSL return failing manage package

SOSL running fine on lower instances with no namespace getting failed in manage package.Although the SOSL EXECUTE returns rows but final output always remains 0. Working fine on unmanage. searchQuery ...
AvengerSF's user avatar
  • 212
3 votes
1 answer
383 views

SOSL query on Lightning Knowledge Articles returns only 250 records even if there are more than 2000+ matching records

Below query returns 250 records FIND {*test*} IN ALL FIELDS RETURNING Knowledge__kav(Id, Title WHERE PublishStatus='online' AND Language= 'en_US') Below query returns 2000 records FIND {*test*} IN ...
Sriram Lns's user avatar
3 votes
1 answer
2k views

SOSL not returning all expected results

I'm trying to SOSL search a custom object we have, by a phone number field but the results are not working as I'd expect. The issue seems to be around missing characters at the start of the search ...
ministe's user avatar
  • 324
7 votes
1 answer
7k views

System Permissions Assigned to Permission Set

Is there a SOQL/SOSL to export/FETCH only the System Permissions from a Specific Permission Set in Salesforce.
Varun SFDC's user avatar
0 votes
1 answer
490 views

How to use dynamic filters in SOSL queries

I have this below 2 SOSL queries. One which is simple one and 2nd is dynamic. I am passing the below data to this method. The 1st SOSL is returning the data, but the dyanamic SOSL is returning NULL. ...
learningmode's user avatar
6 votes
1 answer
873 views

Is there a reliable way to know which SObjects are supported by a SOSL search?

Having some trouble as an ISV with dynamic SOSL. I have a search box that searches all records. When building the SOSL query, I only add objects that have the IsSearchable flag set to true on the ...
Toby Curtis's user avatar
0 votes
1 answer
211 views

SOSL No Result in Apex (Not Test Mode)

I want to query matching Accounts based NRIC Passport No AND Service Agent looking up to custom object Agent__c with a set of Ids (for bulkification) and i'm using: FIND '999999' IN ALL FIELDS ...
Jefferson Fernandez's user avatar
1 vote
1 answer
2k views

SOSL Multiple Search Words

Trying to search multiple terms in SOSL in APEX. I tried this singular, of course works: [FIND 'searchOne' IN ALL FIELDS RETURNING ACCOUNT] But these don't work: [FIND 'searchOne' OR 'searchTwo' .......
Jefferson Fernandez's user avatar
2 votes
2 answers
4k views

SOSL query with special characters

I am building a dynamic SOSL Query searchText = 'AB-C'; searchquery = 'FIND {'+ searchText + '} IN all FIELDS RETURNING Account( id, name, ownerid,website, CMFL__Oppty_Count__c WHERE '+ condition ...
Prady's user avatar
  • 12.2k
4 votes
1 answer
1k views

Does SOSL wildcard (*) work with space characters

I am currently trying to implement a sosl search query, so I can filter out non-letter characters for searching inside the salesforce database. Everything works as expected, however when I encounter a ...
Kobe's user avatar
  • 73
0 votes
1 answer
95 views

"Invalid USING clause" error when using list view in SOSL

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\' ...
dzh's user avatar
  • 4,206
0 votes
1 answer
568 views

SOSL Query Returning Only Empty Lists / No Results

I'm trying to use SOSL to locate Account, Contact, Lead, and Site__c records by Id using a dynamic string of matching ids obtained from Destination__c records. However, I'm not returning any records ...
KB145's user avatar
  • 866
2 votes
1 answer
231 views

SOSL having discrepant results than SOQL for same operation

We are performing SOQL and SOSL operation to find particular value on an object. Please find below code: String searchCustomerMobileNo = '9999999999'; Double mobileNo = Double.valueOf(...
sfdcnoob's user avatar
0 votes
1 answer
2k views

How to implement Dynamic SOSL with 'Contains' keyword

This is an embedded VF page on the Contact detail page. I have this SOSL query to display all the related contact records on every Contact detail page. But for few contacts, email field(of Parent ...
Austin Evans's user avatar
1 vote
2 answers
1k views

SOSL search in master details objects

I have two object A__c(s1__c) and B__c(s2__c) and relationship among them is Master-details. I have to make a SOSL search in field of both(s1__c and s2__c). Find {searchText} Returning A__c(s1__c), ...
Manish's user avatar
  • 11
2 votes
2 answers
317 views

SOSL Query returns an Error

I am trying to display related contacts on the record detail page based on the current Contact record id. For the related contacts, my SOSL as follows: String searchQuery = 'FIND \'' + firstName + ' ...
Austin Evans's user avatar
-3 votes
1 answer
403 views

SOSL not able to fetch records when called from Apex, even though database having matching records

I have been facing a unique kind of issue since the last 2 days, I am using SOSL Query in my Apex. It is working on a partial basis, i.e, returning records perfectly in some cases, while not returning ...
Shobhit Saxena's user avatar
0 votes
1 answer
498 views

expecting a right parentheses SOSL

I am creating a dynamic SOSL which finally executed as below when I print in debug: FIND 'gar,ont2' RETURNING Contact ( Name, FirstName, LastName WHERE (Preferred_First_Name__c like '%gar%' OR ...
C0DEPirate's user avatar
  • 1,599
0 votes
1 answer
482 views

Dynamic sosl query not returning all events with search term in their subject

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*) ...
Tyler Dahle's user avatar
  • 2,609
2 votes
0 answers
180 views

SOSL query on ContentDocument [closed]

I have a requirement to search within files. To get that working, I have a SOSL query on ContentVersion. It seemed to work as expected when I tested as myself, however... I myself seem to get the ...
Kasper's user avatar
  • 2,873
0 votes
1 answer
707 views

Dynamic SOSL SearchQuery with AND Clause for Contact Firstname and Lastname

If i am trying to make a SOSL Search Query dynamic where Firstname and Lastname will be coming from remote parameter dynamically. Attached code sample is not working - But if i make the SOSL Query ...
Nirmallya Ghosh's user avatar
0 votes
1 answer
182 views

Performance issue for searchable 500+ fields

I haven't work on something like this before but what are the performance implication whether using SOQL or SOSL 500 fields+ (fields will be added dynamically as the application grows) and having 800K ...
Nick's user avatar
  • 6,894
1 vote
1 answer
1k views

How to get all email type field values

How to get all email type field values in a salesforce lead record from a record id in apex class.
Bhuvanesh Narayanasamy's user avatar
0 votes
1 answer
1k views

From Parent ID, dynamically derive child's lookup field name/token

I'm trying to save a new record dynamically, but I'm having a problem with a lookup field. For instance, I'm able to get the parent object with the id. Id relatedID = '<someId>'; SObjectType ...
Andrew L.'s user avatar
  • 837
14 votes
4 answers
42k views

Only variable references are allowed in dynamic SOQL/SOSL

I'm trying to re-request an Asset from the database: asset = Database.query('SELECT ID, Price, Asset_MRR__c FROM Asset WHERE id =: ' + asset.id + ' limit 1'); But I get an error: Only variable ...
Sergey's user avatar
  • 551
10 votes
1 answer
2k views

Can we have a ORDER BY Clause in SOSL

I am running a SOSL Query and i want the results to be order by a particular field. System.QueryException: unexpected token: ORDER Here is the query i am building in my apex FIND 'Cisco Systems*' ...
Prady's user avatar
  • 12.2k
2 votes
3 answers
349 views

SOSL: System.QueryException: Non-selective query against large object type (more than 100000 rows)

We have over 100,000 contacts to query the system to get this error. SOSL: System.QueryException: Non-selective query against large object type (more than 100000 rows) However, this error is only ...
user1843608's user avatar
2 votes
1 answer
210 views

Showing matching keyword sentences from SOSL/SOQL results

We have a requirement to search in large text area field (for e.g. Description). We are using SOSL for the same. While showing results on the VF page we want to only few sentence from Description ...
Ashish's user avatar
  • 2,362
3 votes
2 answers
7k views

How do I create a Dynamic SOSL Query

I need to allow a User to narrow their article search by ArticleType when desired My current Controller handles the search input just fine and can also accept a search via a URL parameter. Where I ...
Jason's user avatar
  • 832
7 votes
2 answers
3k views

SOSL query returns only 250 records even if there are more than 2000+ records present

I have two queries List<sobject> soslRecords1 = Search.query('FIND {I need help res*} in all fields returning Incident__c (id) where ID IN:rec_ids')[0]; List<sobject> ...
Shilpa's user avatar
  • 71
3 votes
1 answer
1k views

Interpreting wildcards (eg, * and &) in SOSL queries through the API. Escape or not?

I have a search feature that is implemented with the AJAX toolkit to use SOSL. var results = sforce.connection.search("FIND {" + sanitize(...) + "} IN NAME FIELDS RETURNING ..."); The sanitize(...) ...
Jan Julian's user avatar
  • 2,614
4 votes
5 answers
3k views

Function to properly escape dynamic SOSL input

I have a page that allows users to specify a search term that then gets put into a SOSL Query. Obviously I'm escaping single quotes to prevent injection, but certain input still cause my code to ...
NSjonas's user avatar
  • 10k
5 votes
1 answer
2k views

Escaping reserverved characters in SOSL queries

Escaping reserverved characters with backslash as described in Force documentation (http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_sosl_find.htm) give unexpected ...
dika90's user avatar
  • 181
10 votes
4 answers
10k views

How do I SOSL across objects, matching all records with FIND clause?

To all the expert SOSL gurus lurking out there, I thought this will be an interesting one: I have some SObjects of different types and I want to return their Name values in a single query. In ...
Matt and Neil's user avatar