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
38
votes
3answers
44k 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?
18
votes
3answers
2k 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 ...
13
votes
3answers
8k 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 ...
13
votes
2answers
1k 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, ...
12
votes
1answer
7k 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: ...
10
votes
4answers
17k 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 ...
10
votes
1answer
2k 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. ...
9
votes
1answer
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 ...
9
votes
1answer
147 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, ...
8
votes
1answer
825 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*' ...
8
votes
1answer
1k 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 ...
8
votes
1answer
3k 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 ...
8
votes
1answer
3k 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 ...
8
votes
2answers
1k 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 : ...
7
votes
4answers
6k 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 ...
7
votes
1answer
2k 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 ...
7
votes
1answer
611 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 = '...
7
votes
1answer
1k 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 ...
7
votes
2answers
654 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, ...
7
votes
3answers
729 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 ...
6
votes
6answers
1k 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 ...
6
votes
2answers
543 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. ...
6
votes
1answer
7k 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 ...
6
votes
3answers
2k 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 ...
6
votes
2answers
2k 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 ...
5
votes
1answer
468 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 ...
5
votes
1answer
554 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 {test@example.com} IN EMAIL FIELDS RETURNING Contact(Id, Name), Lead(Id, Name) ...
5
votes
1answer
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 ...
5
votes
1answer
897 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 ...
5
votes
1answer
491 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 ...
5
votes
1answer
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 ...
5
votes
2answers
1k views

Apex SOSL Paging Implementations

How might one implement SOSL paging, i.e. get the next 200 results, in Apex?
5
votes
1answer
82 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 ...
5
votes
1answer
261 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 ...
5
votes
1answer
1k 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> ...
4
votes
1answer
284 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 ...
4
votes
1answer
7k 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 ...
4
votes
1answer
168 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, ...
4
votes
1answer
2k 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 ...
4
votes
1answer
57 views

SOSL Doesn't find data with wildcards

I'm working on a query to find some duplicate records by name. I take the name and replace anything thats not a letter with a wildcard. I wind up with a query that looks like this: FIND {Name*Name*} ...
4
votes
1answer
162 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 ...
4
votes
1answer
46 views

SOSL Behaving Differently in Spring16 vs Winter16

Has anyone else noticed a difference in SOSL on a Spring16 prerelease org? The code has not changed for over a year yet our custom search page has stopped finding results for search strings our end ...
4
votes
1answer
2k 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, ...
4
votes
1answer
232 views

Can we Scan more than 50000 record using SOSL query

As mentioned in Salesforce doc that it can return 2000 records but what about scanning 500K records. Is there any limit on records that will be scanned.
4
votes
3answers
2k views

SOSL returning maximum of 500 records

I am using SOSL to search records in Salesforce. According to document http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_sosl_limit.htm, It should return 2000 records but ...
4
votes
1answer
635 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 ...
4
votes
1answer
598 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<...
4
votes
1answer
452 views

SOSL Filter by Library on Salesforce Content

Is is possible to search Salesforce Content in a specific library (ie. ContentWorkspace)? According to the Content data model, it seems the relationship between ContentWorkspace and ContentVersion ...
4
votes
0answers
406 views

SOSL - Combining results from multiple objects into a single result set [closed]

If you query from multiple objects the SOSL query returns a List<List<SObject>>, with each inner List sorted by relevance inside. I want to return a combined mixed list sorted by relevance ...
4
votes
1answer
267 views

Salesforce search engine vs SOSL

Below is my SOSL query - FIND {searchString} IN ALL FIELDS RETURNING Account(Id,Account_Number__c, RecordType.Name,Name LIMIT 16) 1) When I put searchString = '42430' in sosl query Query 1: ...