November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi Mark,
How are you creating the client? I guess Epi find can't use the standard way to create. What I would have tried is to put the find settings in the appsettings and create the client myself
<appSettings>
<add key="find:service:url" value="yourserviceurl"/>
<add key="find:index" value="yourindex"/>
</appSettings>
And use it in code
//get serviceUrl and indexName values from appSettings
var serviceUrl = ConfigurationManager.AppSettings["find:service:url"];
var indexName = ConfigurationManager.AppSettings["find:index"];
var remoteSearchClient = new Client(serviceUrl, indexName);
var remoteSiteSearchResult = remoteSearchClient.UnifiedSearchFor(query).GetResult();
This is taken from a blog post from Mari Jørgensen https://getadigital.com/no/blogg/episerver-find-and-multiple-indexes/
-Sebastian
Sebastian,
Thank you for the response, but it seems the client is being created properly with var client = Client.CreateFromConfig(); . I've used fiddler and see the requests going to https://usea02.find.episerver.net/
The request is very basic in comparison to the one used directly from EPiServer though.
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "covid",
"analyzer": "standard"
}
},
"filter": {
"term": {
"___types": "EpiSearchConsole.LayoutPageData"
}
}
}
},
"facets": {
"SearchCategories": {
"terms": {
"field": "SearchCategories$$string",
"size": 100
}
}
},
"fields": [
"___types",
"ContentLink.ID$$number",
"ContentLink.ProviderName$$string",
"Language.Name$$string"
]
}
Hi Mark,
Below code worked for me, maybe you can give a try. :)
Just add required references in project and you are good to go. What is important here is projection, refer below article for the same.
public class Program
{
static void Main(string[] args)
{
var client = new Client("Service_Url", "defaultIndex_willBeHere");
var query = client.Search<IProductVariant>(Language.English)
.For(searchTerm)
.InField(x => x.DisplayName)
.InField(x => x.Summary)
.Select(x => new ProjectionModel
{
DisplayName = x.DisplayName,
Summary = x.Summary
}).Take(10);
var searchResults = query.GetResult();
if (searchResults.Count() == 0)
{
Console.WriteLine("No result found");
}
else
{
foreach (var item in searchResults)
{
Console.WriteLine(item.DisplayName);
Console.WriteLine(item.Summary);
Console.WriteLine("-----------------------------------------------------");
}
}
}
}
class ProjectionModel : IProductVariant
{
public string DisplayName { get; set; }
public string Summary { get; set; }
}
@Mari,
Thank you for checking on on this one. Your timing is perfect. I had not solved it but dropped this for a while. I sorted out my issue by working with the entire CMS solution. I have to do some search inhancements again and really wanted to get this console app working. It would be a lot quicker to work with.
@Ashish, thank you for your response, but that didn't work out for me either. I'm not quite sure what I'm doing wrong. This is just a bare bones console app. I was trying to just use UnifiedSearch so I didn't need to bring the entire page object model over from the main solution.
Mark
The UnifiedSearch documentation says:
Note: The GetResult method modifies search queries by searching for objects that implement ISearchContent and for all types added to the UnifiedSearchRegistry. The GetResult method also adds a projection from ISearchContent to UnifiedSearchHit with sensible defaults, along with any type-specific projections added to the UnifiedSearchRegistry. Finally, before executing a search query (such as the GetResult method), Unified Search adds type-specific filters that were added to the UnifiedSearchRegistry.
How is UnifiedSearch "configured" in your main solution? Do you use unified search or typed search? Have you implemented ISearchContent interface or made any changes to conventions (UnifiedSearchRegistry)?
Mari,
Thank you for this. Sorry, I had to sit this down for a while. I think you pointed out some vital information here. ISearchContent has not been implemented. I'll have to look into this and I'll update the thread with my results when I can.
Cheers,
Mark
I just wanted to loop back on this thread. I think the problem I encountered was due to our site having multiple subsites. In the Console application I believe the wrong default filter was being used, and it was filtering results for the wrong SiteId.
I came across this example and it seemed to give me results from all the sites.
This is an excerpt of code that Peter Gustafsson has in that above thread. It was decompiled from Episerver.Find.CMS. The FilterOnCurrentSite<IContentData>() was just commented out, and that allowed for results.
// Code from CmsUnifiedSearchSetUp.cs in Episerver.Find.Cms DLL 13.0.5
var cmsUnifiedSearchSetup = new EPiServer.Find.Cms.CmsUnifiedSearchSetUp();
SearchClient.Instance.Conventions.UnifiedSearchRegistry.Add<PageData>()
.PublicSearchFilter((Func<IClient, ISearchContext, Filter>)((c, ctx) => (Filter)c.BuildFilter<IContentData>()
.FilterForVisitor<IContentData>(this.GetLanguage(ctx)
).ExcludeContainerPages<IContentData>()
.ExcludeContentFolders<IContentData>()
//.FilterOnCurrentSite<IContentData>()
))
.CustomizeIndexProjection(new Func<IndexProjectionBuilder, IndexProjectionBuilder>(cmsUnifiedSearchSetup.CustomizeIndexProjectionForPageData))
.CustomizeProjection(new Func<HitProjectionBuilder, HitProjectionBuilder>(cmsUnifiedSearchSetup.CustomizeProjectionForPageData));
Hello,
I've been trying to setup a little test console application for Episerver Search & Navigation. This is something that the training course does.
We already have an index that we use for development, and have crawled content in there. I can get results back from within Episerver, so I'm doing something wrong in the console app.
I have a reference to the Episerver.Find.Framework package in Nuget, and this setup in the app.config:
<section name="episerver.find" type="EPiServer.Find.Configuration, EPiServer.Find" requirePermission="false" />
<episerver.find serviceUrl="https://usea02.find.episerver.net/[client secret]" defaultIndex="[Index reference]" />
It's a barebones program (see below), but not returning results. I've even tried using fiddler to glean the differences between what's happening in Epi vs. the console. I've tried using Typed vs. Unified as well.
Would someone kindly point me in the right direction please?