Questions tagged [sosl]

SOSL the Salesforce Object Search Language syntax. Use this tag for questions related to SOSL and handling query ouput.

Filter by
Sorted by
Tagged with
42 votes
3 answers
58k views

SOQL vs SOSL - Which one to use and when?

What arguments can be made to use SOQL or SOSL? When would you use one over the other? What is the main difference?
Jesse Altman's user avatar
  • 19.7k
18 votes
3 answers
3k views

Why is SOSL in Test not working?

I have a Custom Object that contains a long text area with 32.000 chars full of comma-separated Ids. I need to find all such records that contain one or more ids. I tried to implement this in this ...
Robert Sösemann's user avatar
14 votes
4 answers
45k 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
14 votes
3 answers
15k views

Is there any way to filter a SOQL or SOSL query on the Id field?

I've tried a number of ways including: SELECT Id, Name FROM Account WHERE Id LIKE '0013%' and FIND { 0013 } IN ALL FIELDS RETURNING Account (Id, Name) and all I receive is the same ...
Darien Ford's user avatar
13 votes
1 answer
10k views

Why does SOSL return a List of a List of sObjects in Apex?

When I use SOSL in Apex (search.query();) the return type is List<List<sObject>>, but I've never run across a case in which there is more than one list returned. For example, this: ...
Matt K's user avatar
  • 3,410
13 votes
1 answer
3k views

Clarification on Unit Testing a method that runs a SOSL query

I have a controller method that uses a SOSL query to generate a list of options. It works when used in the VF page, but the unit test is failing; logging shows the SOSL query is returning no results. ...
Jason Clark's user avatar
  • 11.9k
13 votes
2 answers
2k views

Can SOSL perform full text search on chatter files?

The Document sobject has an IsBodySearchable flag which controls if you can full text search it via SOSL. ContentVersion has no such flag but I know that it is searchable in certain cases. However, ...
Greg Grinberg's user avatar
10 votes
4 answers
11k 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
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.3k
10 votes
1 answer
7k views

SOQL query to fetch records with reserved characters ('*', '/', '(', ')')

Hoping there is a simple answer that I am overlooking. Currently, we are able to search for the following reserved characters with an escape sequence, eg a backslash character '\', in SOSL: & | ! ...
Evelyn Grizzle's user avatar
10 votes
2 answers
2k views

SOSL : FIND '"com"' returning more records than FIND '"com" or "net"'

When trying to search a string using SOSL, it behaves differently for one search parameter vs two search parameters with logical operator. Search String 1 : FIND '"com"' => No of Records Returned : ...
Chirag Mehta's user avatar
  • 1,251
10 votes
1 answer
696 views

SOSL query having issues with quotes (in the record(s) that should be returned, not the query string)

Tried to do some due diligence before asking this one. I have read the SOSL documentation, and have done some cursory searching here on SFSE. Scenario I have an integration with an external system, ...
Derek F's user avatar
  • 61.5k
9 votes
1 answer
2k views

How long does it take for Salesforce to build the SOSL index?

After adding new data to Salesforce, the records do not show up immediately in SOSL queries or the Salesforce search interface. How long does it take for new information to be indexed? I'm looking ...
Benj's user avatar
  • 11.2k
9 votes
1 answer
10k views

SOQL: Bulk Fuzzy Searching

I have a list of accounts that I would like to perform a LIKE query on. Ideally, my query would be something like: SELECT id, owner.name FROM Account WHERE name LIKE IN :entityList Is there any way ...
ZAR's user avatar
  • 2,043
8 votes
1 answer
3k views

Does SOSL allow the `-` dash character?

According to the documentation you need to escape the following special characters in SOSL search text. Escaping special characters & | ! ( ) { } [ ] ^ “ ~ * ? : \ ' The - dash character is ...
dBeltowski's user avatar
  • 3,038
8 votes
1 answer
3k views

SOSL and "ends with" wildcard

I am trying to implement a SOSL search function that uses an "ends with" wildcard, like *searchString in SOQL. No luck! I know about this limitation of SOSL Asterisks match zero or more characters ...
Sergej Utko's user avatar
8 votes
1 answer
4k views

Search formula fields using SOSL

Im trying to build a custom job board search on visualforce. I have a positions object which has a relationship has a master detail field to account. I'd like the search to return positions when you ...
Keith Mancuso's user avatar
7 votes
1 answer
8k views

How to Search a text in all fields in all objects and return all values?

Can I find a string from all fields from all custom and standard objects and return the data (all field data) of all the records that matches for all the fields of those objects?? Also is there an ...
Sathya's user avatar
  • 3,202
7 votes
1 answer
9k 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
7 votes
1 answer
862 views

Relationships in SOSL

Can I use relationships in SOSL? Example: Find all first names that start with 'Roc' within Position__c FIND \'Roc*\' IN ALL FIELDS RETURNING Position__c(Id, Contact__r.FirstName WHERE Title__c = '...
fourq's user avatar
  • 2,111
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
7 votes
1 answer
2k views

Implementing a Keyword Search

A more detailed explanation follows, but the core of my question is: what are best practices for implementing a general keyword search in SOQL/Apex? In an app that I'm building, we're using a data ...
Benj's user avatar
  • 11.2k
7 votes
2 answers
981 views

Duplicate IDs in sandbox - how come?

We've been struggling with an internal server error if the SOSL search text is test: List<List<Account>> accounts = [FIND 'test' IN ALL FIELDS RETURNING Account(Name, Description, ...
geeljire's user avatar
  • 1,256
7 votes
3 answers
1k views

How to search for a long list of arguments

We have reports to search all cases that contain certain serial numbers (strings) in a custom text area field that can contain a comma-separated list of serial numbers. Additionally, serial numbers ...
georg w.'s user avatar
  • 1,224
6 votes
6 answers
2k views

Most efficient (instant / no Batch) way to mark thousands of records as dirty

I have the requirement to store and retrieve the information that a set of arbitrary sobject records are "dirty" and need to be touch by asynch processes. I am talking about 10.000 to 100.000 records ...
Robert Sösemann's user avatar
6 votes
1 answer
2k views

What is the default sort order for records in SOSL

When you search with SOSL but do not specify an ORDER BY clause, does it sort by any particular field? Example: FIND {[email protected]} IN EMAIL FIELDS RETURNING Contact(Id, Name), Lead(Id, Name) ...
Danesh's user avatar
  • 167
6 votes
2 answers
892 views

Check if a .txt file of IDs all exist in Salesforce

I receive a .txt files of type ID, e.g. 003U000000PL9LN, 001U000000PL9LM, a1fU000000PL9LO. I need to check if these IDs correspond to valid objects within Salesforce. I have a List of IDs in Apex. ...
George S.'s user avatar
  • 2,730
6 votes
3 answers
3k views

What is the maximum number of rows that SOQL and SOSL can "scan"?

It's quite clear from the governor limits documentation how many records can be returned, and the docs do mention that SOQL in a trigger will scan a maximum of 100k records. So my questions are: For ...
Wes Nolte's user avatar
  • 2,136
6 votes
1 answer
4k views

Sanitize a string before injecting it into SOSL

Is there a way through the .net framework or some other package to sanitize strings so that they can be safely used in sosl? Is there any larger standard that SOSL falls under? I was able to find How ...
Ryan Gates's user avatar
6 votes
2 answers
1k views

Apex SOSL Paging Implementations

How might one implement SOSL paging, i.e. get the next 200 results, in Apex?
mjgallag's user avatar
  • 965
6 votes
1 answer
987 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
5 votes
1 answer
1k views

Can SOSL be used with more record than SOQL?

Because our client has a LOT of records (I have no idea how much), my colleagues feel it is necessary to use a SOSL query rather than a SOQL query, but I've never heard anything suggesting that SOSL ...
Brian Kessler's user avatar
5 votes
2 answers
3k views

Question about setFixedSearchResults() Apex Tests with SOSL

The documentation on preparing tests for code with SOSL queries includes the comment "Additionally, the test method can call Test.setFixedSearchResults multiple times to define different result ...
Ken's user avatar
  • 364
5 votes
1 answer
16k views

Using SOSL with where clause

Will there be any performance impact when using SOSL with where clause? There are millions of records in one of the custom object. We need to develop custom search functionality where user can select ...
LakhanP's user avatar
  • 821
5 votes
1 answer
1k views

Filter results with not like

I have to query task object to get the rows with subject not starting with 'Email' . I have tried the given query. But it is not working . Please suggest. select status, subject, whatId from task ...
user2703132's user avatar
5 votes
1 answer
3k views

SOQL query FeedItem by community

I would like to query feed items on a specific community, but can't figure out how to do so in SOQL. For example, this query returns no results. SELECT Id,Body,NetworkScope FROM FeedItem WHERE ...
David Reisch's user avatar
5 votes
1 answer
2k views

Find all records referencing a specific Account

What would be the best way to go about listing all the records that reference an Account? Lookup Ids aren't search indexed so SOSL turns up no results when looking for the Account Id and the only ...
Valyrion's user avatar
  • 1,144
5 votes
1 answer
843 views

What is the max length of a SOSL search expression?

My SOSL query with an extremely long search expression failed with System.UnexpectedException: Search Term exceeded max length Searching the Documentation I could not find anything about a max ...
Robert Sösemann's user avatar
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
  • 191
5 votes
1 answer
6k views

SOQL on Rich text fields long text

I'm working on a custom search page, which will search through the fields of the Project object. I use dynamic SOQL query similar to that: SELECT Id, Name, Link_Test__c, ...
Racheli's user avatar
  • 83
5 votes
1 answer
335 views

How do I get SOSL WITH HIGHLIGHT in Apex?

Is it possible to get the highlight field from a SOSL search within apex? For example: List<List<Contact>> results = [ FIND {text} IN ALL FIELDS RETURNING Contact(Id, Name) WITH ...
fehays's user avatar
  • 730
5 votes
1 answer
1k views

Why are no results returned when performing a SOSL query on ContentNote in a Test Method?

Following the example laid out in Adding SOSL Queries to Unit Tests, I created a test method that inserts a ContentNote record, sets the results using Test.setFixedSearchResults(), and then performs a ...
bardsley's user avatar
5 votes
1 answer
928 views

QueryException: Non-selective query against large object type (SOSL)

The following SOSL is in an Account trigger in a managed package: /* Trigger is on API 27.0 */ String acctsNamesOrd = 'PARKER/VANGUARD MGT'; Map<Integer, String> acctsNames = new Map<...
Mossi's user avatar
  • 3,956
5 votes
1 answer
711 views

Sosl on FeedItems with network id

I am trying to query for FeedItems that belong to a specific community as follows: FIND {searchTerm} RETURNING FeedItem(Id,Title,Body) WITH NETWORK IN ('SomeID') However, I noticed that the query ...
glls's user avatar
  • 20.1k
4 votes
3 answers
42k views

SOQL Like Query?

I am trying to make a query that will search for accounts with a name similar or exactly matching a field value. So for example I have "Sales-Force" in the field. There is an account called "...
Alexander Atkinsoon's user avatar
4 votes
3 answers
699 views

Array notation for List<List<Sobject>>

In an attempt to be as byte pinching as possible(personal goal), I have a question some time on Google has not been able to answer. I did look at some Java documentation to try and resolve the issue ...
Genko's user avatar
  • 636
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
  • 10.2k
4 votes
1 answer
439 views

Does SOSL use Caching?

I'm trying to re-factor a trigger because it is operating on a Contact Record type that contains more than 100,000 objects. I easily switched over to the SOSL equivilant, but now my code is behaving ...
Lee Harrison's user avatar
4 votes
1 answer
230 views

SOSL Search Results incomplete?

I have the following SOSL: FIND {*ball*} IN ALL FIELDS RETURNING Campaign(Name, Subscription_Center_Description__c) I have the following 3 campaigns that SHOULD show up: Name: Sportsball, ...
gNerb's user avatar
  • 9,481
4 votes
1 answer
3k views

How to order SOSL results by relevance

How can I order the results of a SOSL query by relevance, meaning the result with the most matches of my OR term first? I have an Apex class that uses SOSL to find potential duplicates for a new bug ...
Robert Sösemann's user avatar

1
2 3 4 5
7