I am trying to implement search in umbraco, i have modified the configuration files and also setup code for search, it is al working fine except it is not getting a property from document type, which is suppose to show page description, and it is accesing all the other properties.
public string loadPageDescription(SearchResult sr) { try { string pageDesc = sr["pageDescription"];//Get an exception here although the property exists and has data return pageDesc; } catch { return sr["nodeName"]; }
Thanks Dawoe for the reply, there were some testing Document types in my project and PageDescription was not included in it, deleted them :) and now it is working fine.
Property Not available in SearchResult
Hi All,
I am trying to implement search in umbraco, i have modified the configuration files and also setup code for search, it is al working fine except it is not getting a property from document type, which is suppose to show page description, and it is accesing all the other properties.
my code is as belows.
Thanks In Advance
Sher
ExamineIndex.config
<IndexSet SetName="WebsiteIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/WebsiteIndexSet/">
</IndexSet>
ExamineSettings.config
<add name="WebsiteIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
dataService="UmbracoExamine.DataServices.UmbracoDataService, UmbracoExamine"
supportUnpublished="false"
supportProtected="false"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
enableDefaultEventHandler="true"/>
<add name="WebsiteSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Code in user control
string[] searchFields = { "nodeName","nodeTypeAlias","pageDescription","bodyText", "nodeName", "siteName", "siteDescription", "mainHeading","heading1","heading2","heading3","heading4","text1","text2","text3","text4",
"previewText","headerText","footerText","streetAddress","city","telephone","fax","email","fAQ"
};
var criteria = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"].CreateSearchCriteria();
var filter = criteria.GroupedOr(searchFields, SearchTerm).Not().Field("umbracoNaviHide", "1").Compile();
SearchResults = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"].Search(filter);
the funtion with exception...
public string loadPageDescription(SearchResult sr)
{
try
{
string pageDesc = sr["pageDescription"];//Get an exception here although the property exists and has data
return pageDesc;
}
catch
{
return sr["nodeName"];
}
}
Maybe you can check with Luke to see if your property is in the index? http://www.getopt.org/luke/
A second check could be that not all nodetypes have the field pageDescription.
Thanks Dawoe for the reply, there were some testing Document types in my project and PageDescription was not included in it, deleted them :) and now it is working fine.
is working on a reply...