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
Balajee SelvarajBalajee Selvaraj 

Error: Compile Error: Method does not exist or incorrect signature: search.query(String) at line 13 column 38

My contorller is:
Public with sharing class soqlExpController{
 Public List<contact> conList{get;set;}
 Public List<account> accList{get;set;}
  Public String Keyword{get;set;}
   Public soqlExpController(){
   }
 
  Public void soslDemo_method(){
   conList = New List<contact>();
   accList = New List<account>();
   String searchStr1 = '*'+keyword+'*';
   String searchQuery = 'FIND \'' +searchStr1+ '*\' IN ALL FIELDS RETURNING  Account (Id,Name,type),Contact(name,email)';
   List<List <sObject>> searchList = search.query(searchQuery);
   accList = ((List<Account>)searchList[0]);
   conList  = ((List<contact>)searchList[1]);
  }
}

MY VF page is:
<apex:page controller="soqlExpController">
  <apex:form >
   <apex:inputText value="{!keyword}"/>
   <apex:commandButton value="Show records using SOSL" action="{!soslDemo_method}"/>
    <apex:pageBlock title="Accounts">
       <apex:pageblockTable value="{!accList }" var="acc">
          <apex:column value="{!acc.name}"/>
          <apex:column value="{!acc.Type}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
 <apex:pageBlock title="Contacts">
    <apex:pageblockTable value="{!conList}" var="con">
      <apex:column value="{!con.name}"/>
      <apex:column value="{!con.email}"/>
 </apex:pageblockTable>
 </apex:pageBlock>
  </apex:form>
</apex:page>
Lalit Mistry 21Lalit Mistry 21
Hi Balajee,
Try using System.Search.query(searchQuery) instead of search.query
Also ensure your class version is not pointing to old version of apex.