Greetings EPiServer gurus.
Picture this scenario:
A customer has got two different EPiServer-sites. One internal and one external website. The external is using EPiServer Find's REST API for search. The internal is currently using a simple Search page which is based upon the Lucene indexer.
The customer wants to be able to search both the external and internal site's content INSIDE the internal site. They are not keen on the idea of having to buy another EPiServer Find license to apply on the internal. So basically they want to be able to search the content of the external site while inside of the internal.
What would be the proper approach in order to do this? Any suggestions appreciated.
/ChrisRun
This is a tricky one. EPiServer Find support multi site setup but requires them to be hosted in the same solution. EPiServer constructed the indexing job in such way that it clears the entire Find index, this means that if you have the same Find index on two different machines they will erase each others indexes, effectively you'll only have the results from the most recently indexed site.
We've discussed this with EPiServer on changing this pattern to only allow an indexer to erase posts with siteId's
available to the solution running the index job. However, no luck so far, instead we rely on hackish solutions :)
So, what you are asking is possible with a bit of coding, reflect the built-in indexer and ensure the ReindexTarget
are scoped correctly (the code is easy to understand). When done this indexing job needs to be used on both the internal and external environment and the original job needs to be removed.
There's no need for filtering in your internal environment but in the external environment you'll have to ensure only external results are posted. If your results include anything else than pages you cannot filter on siteId
since global items (like files and images) doesn't have any siteId. We've solved this with a url-filter like the one below.
private static FilterBuilder<ISearchContent> SiteFilterBuilder
{
get
{
var filter = SearchClient.Instance.BuildFilter<ISearchContent>();
filter = filter.Or(x => x.SearchHitUrl.Prefix(EPiServer.Web.SiteDefinition.Current.SiteUrl.AbsoluteUri));
return filter;
}
}
Implement
var query = SearchClient.Instance.UnifiedSearch(Language.Swedish)
.For(searchQuery.Query)
.AndInField(x => x.SearchCategories)
.UsingSynonyms()
.OrFilter(SiteFilterBuilder) // will scope to this site
.ApplyBestBets()
.Track()
.TermsFacetFor(x => x.SearchSection)
;