November Happy Hour will be moved to Thursday December 5th.

How to exclude contentlink id in search result

Vote:
 

Hi guys, 

I have a problem when a customer search a product code(Article number) e.g. 1512 in Find.

It included a product which have ContentLink ID 1512 (product code 70405) in search result.

How can I exclude the contentlink id in the search result?

I have the following code:

multiSearch = searchClient.Search<ContentData>()
.For(query)
.FilterByExactTypes(new[] { typeof(Article), typeof(Category), typeof(StandardPage) })
.FilterForVisitor(currentLanguage)
.FilterMarket(new IMarket[] {currentMarket})
.Skip(skip).Take(itemsPerPage).Track().GetContentResult();

Thanks, 

ChiChing

#199720
Dec 07, 2018 11:39
Vote:
 

If you want to search in specific fields, you can probably try out InFields 

https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/

There is no "exclude fields" APIs that I know of 

#199729
Dec 07, 2018 14:37
Vote:
 

Thanks Quan! 

I use the following search for standardpage, category and article.

multiSearch = searchClient.Search<ContentData>()
.For(query)
.FilterByExactTypes(new[] { typeof(Article), typeof(Category), typeof(StandardPage) })
.FilterForVisitor(currentLanguage)
.FilterMarket(new IMarket[] {currentMarket})
.Skip(skip).Take(itemsPerPage).Track().GetContentResult();

I would like to include page name, preamble and mainbody in standard page search result. 

For article, I would like to include article code(product number), name, description etc. 

Would you like to give me some tips how do I have InFields for different types(standard page, article)?

I found also an article about "Exclude field from search", someone has impemented an exstensions method for excludedfields.

https://world.episerver.com/forum/developer-forum/EPiServer-Search/Thread-Container/2013/9/Exclude-field-from-search/

#199815
Dec 12, 2018 11:32
Vote:
 

Yes it is basically just the reverse of InField. More convenient, yes, but works the same 

#199816
Dec 12, 2018 11:37
Vote:
 

Hi ChiChing & Quan,

How did you fix for ContentLink ID 1512 to be excluded from search query?

#226565
Aug 14, 2020 18:06
* 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.