Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Unified Search Filter by a specific Property Value

Vote:
 

Hi

I have implimented the serach page by taking reference from Aloy site. It is unified search result. Now I have to filter the current result by Property Values BrandName and PublishDate.

  1. Is it possible with the current Unified result?
  2. I have tried it by GetPagesResult, but by this Doucment URL and Excepert become empty in my serach result

Please suggect me asap.

Thanks

Abhishek

#179188
Jun 02, 2017 12:34
Vote:
 

Hello @Abhishek,

Take a look at these previous forum posts:

Forum post #1 - This post explains how to include properties into the index by creating an initialization module.

Forum post #2 - This post explains how to return the data that's included in the index.

Hope this helps!

-RJ

#179198
Jun 02, 2017 17:32
Vote:
 

Hi RJ,

Thanks for the reply. I doesn't got the hits after applying suggested solution.

First I have created the follwoing Extn method to refernce "BrandName" property.

public static IEnumerable<string> ReferenceBrands<T>(this T content)
{
var file = content as IContent;
//if (file != null)
//{
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var references = contentRepository.GetReferencesToContent(file.ContentLink, false);
foreach (var referenceInformation in references)
{
PageData page = null;
contentRepository.TryGet(referenceInformation.OwnerID, out page);
if (page != null)
yield return page.GetPropertyValue("BrandName");

}
//}
}

After that include it in index :   SearchClient.Instance.Conventions.ForInstancesOf<PageData>().IncludeField(x => x.ReferenceBrands());

Build Index.

Update by query as :

var queryFor = searchClient.UnifiedSearch().For(model.Query);


if (model.UseAndForMultipleSearchTerms)
{
queryFor = queryFor.WithAndAsDefaultOperator();
}

var query = queryFor
.UsingSynonyms()
.UsingAutoBoost(TimeSpan.FromDays(30))
.Filter(x=>x.ReferenceBrands().Match("Manpower"))
.TermsFacetFor(x => x.ReferenceBrands())
.FilterFacet("AllSections", x => x.ReferenceBrands().Exists())
.Skip((model.PagingPage - 1) * model.CurrentPage.PageSize)
.Take(model.CurrentPage.PageSize)
.ApplyBestBets();

PLease suggest.

Thanks

Abhishek

#179204
Jun 02, 2017 22:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.