Hi All,
We have a requirement in the project to search the content from only those sites which are created using custom site definition.
We have configured custom "Result Sources" using Query "WebTemplate:<SiteDefName>" and did a full crawl.
We added a Search Results web part and in web part properties, change the query as "WebTemplate:<SiteDefName>", it's showing correct results in the preview pane while clicking on Test Query button. But in real search, it's showing only one result. Though, we have not provided any other refiners or filters for the results. Are we missing any setting to display all the results?
We tried the same approach with Content Search web part, which is working correctly as expected.
Also, we tried the KQL to find the results programmatically using below code-
using (SPSite site = newSPSite(SPContext.Current.Site.Url))
{
KeywordQuery keywordQuery =newKeywordQuery(site);
keywordQuery.QueryText = "WebTemplate:LearningGroup";// LearningGroup is the custom site definition name
SearchExecutor searchExecutor =newSearchExecutor();
ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
var resultTables = resultTableCollection.Filter("TableType",KnownTableTypes.RelevantResults);
int totalRows = resultTables.Count();
var resultTable = resultTables.FirstOrDefault();
DataTable dataTable = resultTable.Table;
int iRowsCount = dataTable.Rows.Count;
}
But this also returns only one item, not all the items. Is there any property missing to fetch all the results programmatically?
Is there a way to retrieve the results from Content Search web part programmatically as well?