ASPX templates
Version 7.x > ASPX templates > Smart Search - exclude archived document View modes: 
User avatar
Member
Member
seanbun - 6/11/2013 7:01:08 PM
   
Smart Search - exclude archived document
Apparent, smart search indexes include published and archived document. How could I only index published document only?

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 6/12/2013 4:57:29 AM
   
RE:Smart Search - exclude archived document
Hello,

Even though the archived and unpublished files are indexed, they should not show up in the search results if set up correctly. Do you have such problem?

The only way to remove the archived files from indexing would be through customization.

Regards,
Josef Dvorak

User avatar
Member
Member
seanbun - 6/12/2013 7:20:21 PM
   
RE:Smart Search - exclude archived document
I am using SearchHelper to do the search. How could I exclude the unpublished/archived documents? I could not find related properties in the SearchParamenters.
 SearchParameters param = new SearchParameters();
DataSet ds = SearchHelper.Search(param);

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 7/4/2013 9:18:20 AM
   
RE:Smart Search - exclude archived document
Hello,

Even when using API, the unpublished documents should not show up. I have been trying to replicate the behaviour you are describing, but I was unable to make the unpublished document to show up in the search results. This is a simple code I was using, with /Home document being un-published:

        SearchParameters param = new SearchParameters();

param.SearchFor = txtSearchInput.Text;
param.Path = "/Home";
param.ClassNames = "CMS.MenuItem";
param.CurrentCulture = "EN-US";
param.DefaultCulture = CultureHelper.DefaultCulture.IetfLanguageTag;
param.SearchSort = SearchHelper.GetSort("##SCORE##");
param.CombineWithDefaultCulture = false;
param.CheckPermissions = false;
param.SearchInAttachments = false;
param.SearchIndexes = "CorporateSite.Default";
param.DisplayResults = 100;
param.StartingPosition = 0;
param.NumberOfProcessedResults = 100;
param.User = CMSContext.CurrentUser;
param.AttachmentWhere = "";
param.AttachmentOrderBy = "";

DataSet ds = SearchHelper.Search(param);

if (ds != null)
{
grvSearchOutput.DataSource = ds;
grvSearchOutput.DataBind();
}
else
{
lblSearchOutput.Text = "Nothing.";
}


If it is similar to yours, could you please post it too, so that I can test it on my local environment?

Regards,
Josef Dvorak

User avatar
Certified Developer v6
Certified Developer v6
Dave - 8/1/2013 12:11:00 PM
   
RE:Smart Search - exclude archived document
I am also experiencing archived documents in my search results. Here is my code (this is being called inside a DataSourceView.Execute method that contains some dynamic properties).


SearchParameters parameters = new SearchParameters()
{
SearchFor = searchFor,
SearchSort = SearchHelper.GetSort(arguments.SortExpression),
Path = this.Path,
ClassNames = this.ClassNames,
CurrentCulture = culture,
DefaultCulture = culture,
CombineWithDefaultCulture = false,
CheckPermissions = true,
SearchInAttachments = false,
User = (UserInfo)CMSContext.CurrentUser,
SearchIndexes = this.SearchIndexes,
StartingPosition = arguments.StartRowIndex,
DisplayResults = arguments.MaximumRows,
NumberOfProcessedResults = arguments.MaximumRows,
NumberOfResults = 0,
AttachmentWhere = String.Empty,
AttachmentOrderBy = String.Empty,
BlockFieldOnlySearch = false,
};

var results = SearchHelper.Search(parameters);

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 8/5/2013 8:29:07 AM
   
RE:Smart Search - exclude archived document
Hello Dave,

I have tested your code (as part of regular web part) with some modifications, and it is working correctly for me. Could you please debug you code and send me the values assigned to the parameters?

This is what I have tested:

SearchParameters parameters = new SearchParameters()
{
SearchFor = txtSearchInput.Text,
SearchSort = SearchHelper.GetSort("##SCORE##"),
Path = txtSearchPath.Text,
ClassNames = "CMS.MenuItem",
CurrentCulture = "EN-US",
DefaultCulture = CultureHelper.DefaultCulture.IetfLanguageTag,
CombineWithDefaultCulture = false,
CheckPermissions = true,
SearchInAttachments = false,
User = (UserInfo)CMSContext.CurrentUser,
SearchIndexes = "CorporateSite.Default",
StartingPosition = 0,
DisplayResults = 100,
NumberOfProcessedResults = 100,
NumberOfResults = 0,
AttachmentWhere = String.Empty,
AttachmentOrderBy = String.Empty,
BlockFieldOnlySearch = false,
};


And again it is not showing up the archived documents. If you send me the exact values assigned to the parameters, I will try some more tests.

Regards,
Josef Dvorak

User avatar
Certified Developer v6
Certified Developer v6
Dave - 8/5/2013 8:36:04 AM
   
RE:Smart Search - exclude archived document
Hi Josef,

Thanks for responding - I actually found the issue, it was not actually a problem with Kentico's code. I had been programmatically archiving documents and neglected to trigger a Search Task for the update document(s). Once I added that, it worked.

Thanks!