+ Start a Discussion
snoftlesnoftle 

Is there a delay in new records being available to visualforce/apex soql searches?

My first post to this group I'm stumped, thank you for any help

 

I've created a simple visualforce page to search fields on a cusotm object.

 

I originally imported around 38,000 records with data loader BEFORE I build the page... these records are found by my search page just fine.

 

Just when I have my page the way I want it will not find any NEW records I create, either by doing them one at a time through the regular UI, or by importing them.

 

I'm searching on the "Name field" so nothing fancy, and System Admin is the only user as this is a new production system so I don't think permissions are the problem...

 

Any help?

 

sfdcfoxsfdcfox

SOSL is subject to the limitations of the Search Index Engine (or whatever it's technical term is called). The SIE (as I'll call it) farms records for indexing as they're created; bulk inserts usually take a while to catch up (a few seconds to a few minutes at most, unless the system specifically tells you that the SIE is behind). SOSL is therefore considered to be an index-only query. SOQL does not suffer from this limitation, as it uses an indexed table scan. The results are slower, but are always accurate to precisely what is in the database when you perform the query. If you are experiencing problems, I would suggest you look at your filters. Also note that you might be running into some Visualforce limitation on number of rows, heap space, or some other condition. If all else fails, try submitting a case to the Developer Support Team. You can also post your code (if you're allowed), and we'll see if we can help you out with the problem. I suspect that it might be difficult to reproduce, but if you have an obvious error, we should be able to spot it.

snoftlesnoftle

Thank you for the reply, I've posted by code below as I don't really think I know the difference between SOSL, and SOQL, (I'm coming from PHP here you'll be able to tell!) 

 

This is just a custom object called "companies" and once all of our data is imported it will not change too much so which ever way our users can search faster is better for us.

 

Again no problem returning any OLD records... just not NEW records....

 

However the built in search function in salesfoce finds my NEW records just fine...

 

 



 <apex:page controller="theController" tabStyle="Companies__c">
<apex:sectionHeader title="Master Company Search"/>
<apex:form >
<apex:pageBlock mode="edit" id="block" title="Refine your search, 100 records at a time will be displayed...">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:panelGroup >
<table cellpadding="0" width="100%">
<tr>
<td>
<p>Business Type:</p>
<apex:selectList id="businesstypeKeyword" value="{!businesstypeKeyword}" size="1" required="true">
<apex:selectOption itemValue="%" itemLabel=""/>
<apex:selectOption itemValue="Load Broker" itemLabel="Load Broker/Freight Forwarder"/>
<apex:selectOption itemValue="Transportation" itemLabel="Transportation and Warehousing"/>
<apex:selectOption itemValue="%" itemLabel=""/>
<apex:selectOption itemValue="Accommodation" itemLabel="Accommodation and Food Services"/>
<apex:selectOption itemValue="Agriculture" itemLabel="Agriculture; Forestry; Fishing and Hunting"/>
<apex:selectOption itemValue="Arts" itemLabel="Arts; Entertainment and Recreation"/>
<apex:selectOption itemValue="Construction" itemLabel="Construction"/>
<apex:selectOption itemValue="Distributor" itemLabel="Distributor"/>
<apex:selectOption itemValue="Educational" itemLabel="Educational Services"/>
<apex:selectOption itemValue="Finance" itemLabel="Finance"/>
<apex:selectOption itemValue="Health" itemLabel="Health Services"/>
<apex:selectOption itemValue="Cultural" itemLabel="Information and Cultural Industries"/>
<apex:selectOption itemValue="Jobber" itemLabel="Jobber"/>
<apex:selectOption itemValue="Manufacturer" itemLabel="Manufacturer"/>
<apex:selectOption itemValue="Mining" itemLabel="Mining and Oil & Gas Extraction"/>
<apex:selectOption itemValue="Professional" itemLabel="Professional; Scientific & Technical Services"/>
<apex:selectOption itemValue="Real Estate" itemLabel="Real Estate"/>
<apex:selectOption itemValue="Rental" itemLabel="Rental and Leasing Services"/>
<apex:selectOption itemValue="Retail" itemLabel="Retail"/>
<apex:selectOption itemValue="Services" itemLabel="Services"/>
<apex:selectOption itemValue="Waste" itemLabel="Support; Waste Management and Remediation Services"/>
<apex:selectOption itemValue="Utilities" itemLabel="Utilities"/>
<apex:selectOption itemValue="Wholesale" itemLabel="Wholesale Agents & Brokers"/>
<apex:selectOption itemValue="Wholesaler" itemLabel="Wholesaler"/>
</apex:selectList>
</td>
<td width="10">&nbsp;</td>
<td>
<p>Products: (or "contains")</p>
<apex:inputText id="productKeyword" value="{!productKeyword}"/>
</td>
</tr>
</table>

<table cellpadding="0" width="100%">
<tr>
<td>
<p>Company Name: (or "starts with")</p>
<apex:inputText id="nameKeyword" value="{!nameKeyword}"/>
</td>
<td>
<p>State:</p>
<apex:selectList id="stateKeyword" value="{!stateKeyword}" size="1" required="true">
<apex:selectOption itemValue="%" itemLabel=""/>
<apex:selectOption itemValue="AB" itemLabel="AB"/>
<apex:selectOption itemValue="BC" itemLabel="BC"/>
<apex:selectOption itemValue="MB" itemLabel="MB"/>
<apex:selectOption itemValue="NB" itemLabel="NB"/>
<apex:selectOption itemValue="NF" itemLabel="NF"/>
<apex:selectOption itemValue="NS" itemLabel="NS"/>
<apex:selectOption itemValue="NT" itemLabel="NT"/>
<apex:selectOption itemValue="NU" itemLabel="NU"/>
<apex:selectOption itemValue="ON" itemLabel="ON"/>
<apex:selectOption itemValue="PE" itemLabel="PE"/>
<apex:selectOption itemValue="QC" itemLabel="QC"/>
<apex:selectOption itemValue="SK" itemLabel="SK"/>
<apex:selectOption itemValue="YT" itemLabel="TY"/>
<apex:selectOption itemValue="%" itemLabel=""/>
<apex:selectOption itemValue="AK" itemLabel="AK"/>
<apex:selectOption itemValue="AL" itemLabel="AL"/>
<apex:selectOption itemValue="AR" itemLabel="AR"/>
<apex:selectOption itemValue="AZ" itemLabel="AZ"/>
<apex:selectOption itemValue="CA" itemLabel="CA"/>
<apex:selectOption itemValue="CO" itemLabel="CO"/>
<apex:selectOption itemValue="CT" itemLabel="CT"/>
<apex:selectOption itemValue="DC" itemLabel="DC"/>
<apex:selectOption itemValue="DE" itemLabel="DE"/>
<apex:selectOption itemValue="FL" itemLabel="FL"/>
<apex:selectOption itemValue="GA" itemLabel="GA"/>
<apex:selectOption itemValue="HI" itemLabel="HI"/>
<apex:selectOption itemValue="IA" itemLabel="IA"/>
<apex:selectOption itemValue="ID" itemLabel="ID"/>
<apex:selectOption itemValue="IL" itemLabel="IL"/>
<apex:selectOption itemValue="IN" itemLabel="IN"/>
<apex:selectOption itemValue="KS" itemLabel="KS"/>
<apex:selectOption itemValue="KY" itemLabel="KY"/>
<apex:selectOption itemValue="LA" itemLabel="LA"/>
<apex:selectOption itemValue="MA" itemLabel="MA"/>
<apex:selectOption itemValue="MD" itemLabel="MD"/>
<apex:selectOption itemValue="ME" itemLabel="ME"/>
<apex:selectOption itemValue="MI" itemLabel="MI"/>
<apex:selectOption itemValue="MN" itemLabel="MN"/>
<apex:selectOption itemValue="MO" itemLabel="MO"/>
<apex:selectOption itemValue="MS" itemLabel="MS"/>
<apex:selectOption itemValue="MT" itemLabel="MT"/>
<apex:selectOption itemValue="NC" itemLabel="NC"/>
<apex:selectOption itemValue="ND" itemLabel="ND"/>
<apex:selectOption itemValue="NE" itemLabel="NE"/>
<apex:selectOption itemValue="NH" itemLabel="NH"/>
<apex:selectOption itemValue="NJ" itemLabel="NJ"/>
<apex:selectOption itemValue="NM" itemLabel="NM"/>
<apex:selectOption itemValue="NV" itemLabel="NV"/>
<apex:selectOption itemValue="NY" itemLabel="NY"/>
<apex:selectOption itemValue="OH" itemLabel="OH"/>
<apex:selectOption itemValue="OK" itemLabel="OK"/>
<apex:selectOption itemValue="OR" itemLabel="OR"/>
<apex:selectOption itemValue="PA" itemLabel="PA"/>
<apex:selectOption itemValue="RI" itemLabel="RI"/>
<apex:selectOption itemValue="SC" itemLabel="SC"/>
<apex:selectOption itemValue="SD" itemLabel="SD"/>
<apex:selectOption itemValue="TN" itemLabel="TN"/>
<apex:selectOption itemValue="TX" itemLabel="TX"/>
<apex:selectOption itemValue="UT" itemLabel="UT"/>
<apex:selectOption itemValue="VA" itemLabel="VA"/>
<apex:selectOption itemValue="VT" itemLabel="VT"/>
<apex:selectOption itemValue="WA" itemLabel="WA"/>
<apex:selectOption itemValue="WI" itemLabel="WI"/>
<apex:selectOption itemValue="WV" itemLabel="WV"/>
<apex:selectOption itemValue="WY" itemLabel="WY"/>
</apex:selectList>
</td>
<td>
<p>City: (or "contains")</p>
<apex:inputText id="cityKeyword" value="{!cityKeyword}"/>
</td>
</tr>
</table>
<p><apex:commandButton value="Search" action="{!doSearch}" rerender="block" status="status"/></p>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<p><apex:actionStatus id="status" startText="Searching Records..."/></p>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}" style="width:100%">
<apex:column headerValue="Company Name">
<apex:outputLink value="https://na1.salesforce.com/{!l.Id}" target="_blank">
{!l.name}
</apex:outputLink>
</apex:column>
<apex:column headerValue="State" value="{!l.State_Provnice__c}"/>
<apex:column headerValue="City" value="{!l.City__c}"/>
<apex:column headerValue="Buisness Type" value="{!l.Business_Type_1__c}"/>
<apex:column headerValue="Products" value="{!l.Product_Category_1__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class theController {

String nameKeyword;
public String getnameKeyword()
{
return nameKeyword;
}
public void setnameKeyword(String s)
{
nameKeyword = s;
}

String stateKeyword;
public String getstateKeyword()
{
return stateKeyword;
}
public void setstateKeyword(String s)
{
stateKeyword = s;
}

String cityKeyword;
public String getcityKeyword()
{
return cityKeyword;
}
public void setcityKeyword(String s)
{
cityKeyword = s;
}

String businesstypeKeyword;
public String getbusinesstypeKeyword()
{
return businesstypeKeyword;
}
public void setbusinesstypeKeyword(String s)
{
businesstypeKeyword = s;
}

String productKeyword;
public String getproductKeyword()
{
return productKeyword;
}
public void setproductKeyword(String s)
{
productKeyword = s;
}


List results;

public List getResults() {
return results;
}

public PageReference doSearch() {
results = [SELECT Id, Name, State_Provnice__c, City__c, Business_Type_1__c, Product_Category_1__c from Companies__c where Name like :nameKeyword+'%' AND State_Provnice__c like :stateKeyword
AND City__c like :'%'+cityKeyword+'%' AND (Business_Type_1__c like :'%'+businesstypeKeyword+'%' or Business_Type_2__c like :'%'+businesstypeKeyword+'%' or Business_Type_3__c like :'%'+businesstypeKeyword+'%')
AND (Product_Category_1__c like :'%'+productKeyword+'%' or Product_Category_2__c like :'%'+productKeyword+'%' or Product_Category_3__c like :'%'+productKeyword+'%' or Product_Category_4__c like :'%'+productKeyword+'%' or Product_Category_5__c like :'%'+productKeyword+'%' or Product_Category_6__c like :'%'+productKeyword+'%')
ORDER BY Name LIMIT 100];

return null;
}

}

sfdcfoxsfdcfox
Your code looks more or less sound, and I don't see any obvious reason why new records would not be appearing. This makes me suspect that your new records are missing one or more data fields (i.e. not all values on each record are populated), which would be a potential problem. It could just be that you're matching older records by coincidence and reaching your proposed 100 record maximum. Try reviewing your data and see if you're missing data in any fields.