How Configure Examine Searcher to exclude deleted pages
Hi,
The content search (using Examine) on our websites is broken. The issues can be separated into three distinct categories:
Search is returning deleted pages: I am not sure how to remove the deleted contents from the search result. Is there an way to add a filter criteria to exclude deleted pages?
Search is returning content from all the sites: We are running two websites for two different countries (Australia and New Zealand) in one Umbraco instance. The issue is that search result is returning pages from both the sites. We don't need AU pages on NZ search result and vice versa. How to create a search query to restrict it to a specific root node id?
Bringing up pages without a template: Some content nodes don't have templates associated with them and meant to be displayed as a part of a parent node. Is there an way to restrict the search to specific document types? But, if the content is found on a sub node, bring up the parent node with a specific doc type?
I am probably asking too many questions in one post, but I guess other users might have faced such issues before.
The code I am using till now:
private List<SiteSearchResult> GetSiteResults(string query, out int totalResults)
{
var criteria = ExamineManager.Instance
.SearchProviderCollection["WebSearcher"]
.CreateSearchCriteria(IndexTypes.Content);
var filter =
criteria.GroupedOr(
new[]
{
"nodeName", "heading", "content", "metaKeywords", "title", "umbracoNaviHide", "umbracoUrlName",
"umbracoUrlAlias", "metaCategory", "metaDescription", "metaTags", "heading", "subHeading",
"quote", "author", "socialCopy", "socialTitle", "socialTitle2", "thumbTitle", "thumbTitle2",
"thumbCopy", "thumbQuote", "url", "location"
}, query)
.Compile();
var searchResults =
ExamineManager.Instance.SearchProviderCollection["WebSearcher"].Search(filter)
.OrderByDescending(x => x.Score);
totalResults = searchResults.Count();
var results = new List<SiteSearchResult>();
foreach (var item in searchResults)
{
var heading = "";
var copy = "";
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var url = umbracoHelper.Url(item.Id, UrlProviderMode.Relative);
if (url.Length == 0)
{
continue;
}
if (url.StartsWith("/forms/"))
{
continue;
}
// Do many things here
results.Add(r);
}
return results;
}
I see you use the custom index, so you can set the config supportUnpublished="false" in the config of custom indexer. So you only index and search the published content.
You can custom the GatheringNodeData event of your indexer to add a field that contains the search_path (replace the comma to space), only and search documents have the root node of each language is in the search_path.
You can set the specific document type for custom indexer, and custom the GatheringNodeData event to modify or add some field that you need to filter. When search, add the filter for this.
You can see some link listed below to have some more information:
http://24days.in/umbraco/2013/getting-started-with-examine/
http://thecogworks.co.uk/blog/posts/2013/february/examiness-hints-and-tips-from-the-trenches-part-8-custom-indexing/
If you have any more questions, please post at here, someone can help you.
How Configure Examine Searcher to exclude deleted pages
Hi,
The content search (using Examine) on our websites is broken. The issues can be separated into three distinct categories:
Search is returning deleted pages: I am not sure how to remove the deleted contents from the search result. Is there an way to add a filter criteria to exclude deleted pages?
Search is returning content from all the sites: We are running two websites for two different countries (Australia and New Zealand) in one Umbraco instance. The issue is that search result is returning pages from both the sites. We don't need AU pages on NZ search result and vice versa. How to create a search query to restrict it to a specific root node id?
Bringing up pages without a template: Some content nodes don't have templates associated with them and meant to be displayed as a part of a parent node. Is there an way to restrict the search to specific document types? But, if the content is found on a sub node, bring up the parent node with a specific doc type?
I am probably asking too many questions in one post, but I guess other users might have faced such issues before.
The code I am using till now:
Thanks, Sudipta
Hi Sudipta,
supportUnpublished="false"
in the config of custom indexer. So you only index and search the published content.GatheringNodeData
event of your indexer to add a field that contains thesearch_path
(replace the comma to space), only and search documents have the root node of each language is in thesearch_path
.GatheringNodeData
event to modify or add some field that you need to filter. When search, add the filter for this.You can see some link listed below to have some more information: http://24days.in/umbraco/2013/getting-started-with-examine/ http://thecogworks.co.uk/blog/posts/2013/february/examiness-hints-and-tips-from-the-trenches-part-8-custom-indexing/
If you have any more questions, please post at here, someone can help you.
Hope you get the solution.
is working on a reply...