function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
R R MR R M 

Method does not exist or incorrect signature: void query(String) from the type Search at line 12 column 45

Hi Folks, 
Error : Method does not exist or incorrect signature: void query(String) from the type Search at line 12 column 45    

Please help me. 

Apex Class: -

public with sharing class TestSOSLController {
Public List<account> accList{get;set;} 
 Public String searchStr{get;set;}
   Public TestSOSLController(){
   }
  
  Public void soslDemo_method(){
   accList = New List<account>();
   if(searchStr.length() > 1){
   String searchStr1 = '*'+searchStr+'*';   
   String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Account (Id,Name,Type,Rating,Phone)';
   List<List <sObject>> searchList = search.query(searchQuery);
   accList = ((List<Account>)searchList[0]);
   
   if(accList.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, no results returned with matching string..'));
       return;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least two characters..'));
   return;
   }
  }
}

v varaprasadv varaprasad
Hi R R M,

Please check once any existing class in your org with a name search.If there please remove or rename it.
 So your problem will solve.

Hope this helps,

Thanks
Varaprasad
R R MR R M
HI Varaprasad, 

I have changed name of Search with Searching and i did cross verified in Existing classes But Same error am recieving while compile. 

Please help.
uttam jaishwal 8uttam jaishwal 8
You have to save ur code