Can Search service return only published search results
Hi,
We are using the search service to search against a dynamic module:
var service = ServiceBus.ResolveService<ISearchService>();
var compiledQuery = query.BuildQuery(string.Concat(term, "*"), new string[] "RecipeName" );
compiledQuery.IndexName = "our-index";
var results = service.Search(compiledQuery);
While it does return an IResultSet object, we are being forced to retrieve each search result again to ensure it is published content. Unfortunately, we taking a performance hit because of this extra work:
foreach(var result in results)
var recipe = dynamicManager.GetDataItem(recipeType, Guid.Parse(result.Fields.SingleOrDefault(f => f.Name == "Id").Value.ToString()));
if(recipe.IsPublished() && recipe.Visible)
//other stuff
Is there a way to specify in the compiledQuery variable that I want to return only Published content?
Thanks,
Gary
Hello,
The search service only returns published items as only the published items are indexed.
There is no need to perform additional queries to ensure that.
For you information, here's a KB article that handles about
How to search programmatically in Sitefinity
Should you continue to have issues with this, please provide additional details including screenshots that demonstrate the behavior in order for us to test.
Regards,
Dimitri Cools
Telerik
Perfect, thanks Dimitri.