Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, I am wondering how to add searchers in Umbraco 10.
Currently I am trying to implement a basic site search with the following code:
@using Umbraco.Cms.Web.Common.PublishedModels; @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels; @using Examine @inject IExamineManager ExamineManager @{ Layout = "Master.cshtml"; } @{ var query = Context.Request.Query["q"]; var canGetSearcher = ExamineManager.TryGetSearcher("ExternalSearcher", out var searcher); var count = ExamineManager.RegisteredSearchers.Any(); <p>@count</p> if (canGetSearcher) { <p>here</p> var searchResults = searcher.Search(query.ToString()); if(searchResults.Any()) { <ul> @foreach (var result in searchResults) { if (result.Id != null) { var node = Umbraco.Content(result.Id); <li> <a href="@node.Url()">@node.Name</a> </li> } } </ul> } } }
I don't see that I have available "searchers" in the back office. I do see the indexes, of course. How do I add a searcher?
Hi Brian,
Just wondering if you worked this one out by any chance? I am facing same issue with my Umbraco 10 website and not able to figure out why
Any kind of help would be really appreciated.
Thank you in advance
Hi
You have to add your seacher to Startup.cs:
public void ConfigureServices(IServiceCollection services) { services.AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddComposers() .Build(); services.AddExamineLuceneMultiSearcher("<seacherName>", new[] { Umbraco.Cms.Core.Constants.UmbracoIndexes.ExternalIndexName, PdfIndexConstants.PdfIndexName });
}
You should then be able to use the seacher in code:
if (_examineManager.TryGetSearcher("<seacherName>", out var searcher)) {
... }
https://docs.umbraco.com/umbraco-cms/reference/searching/examine/pdfindex-multisearcher
Thank you so much Lars for your reply, I am using the same solution like this:
builder.Services.AddExamineLuceneMultiSearcher("ExternalSearcher", new[] { Constants.UmbracoIndexes.ExternalIndexName });
How ever, doesn't this externalsearcher have to come default? ( just like in umbraco 7 and 8 ). Is there any configuration setting that enables it in Umbraco 10?
You must register the seacher in startup before you can see it under Examine Management.
public void ConfigureServices(IServiceCollection services) { services.AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddComposers() .Build(); services.AddExamineLuceneMultiSearcher("<seacherName>", new[] { Umbraco.Cms.Core.Constants.UmbracoIndexes.ExternalIndexName, PdfIndexConstants.PdfIndexName }); }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Simple Site Search Umbraco 10
Hi, I am wondering how to add searchers in Umbraco 10.
Currently I am trying to implement a basic site search with the following code:
I don't see that I have available "searchers" in the back office. I do see the indexes, of course. How do I add a searcher?
Hi Brian,
Just wondering if you worked this one out by any chance? I am facing same issue with my Umbraco 10 website and not able to figure out why
Any kind of help would be really appreciated.
Thank you in advance
Hi
You have to add your seacher to Startup.cs:
}
You should then be able to use the seacher in code:
... }
https://docs.umbraco.com/umbraco-cms/reference/searching/examine/pdfindex-multisearcher
Thank you so much Lars for your reply, I am using the same solution like this:
How ever, doesn't this externalsearcher have to come default? ( just like in umbraco 7 and 8 ). Is there any configuration setting that enables it in Umbraco 10?
You must register the seacher in startup before you can see it under Examine Management.
is working on a reply...