Exclude certain entries in index from unified search

Vote:
 

Hello!

I have some properties in the index (urls etc) that we would like to not get a hit in when we do an unified search.

Is there a way (an attribute, filter etc) to exclude certain properties from an unified search? We need them in the index. just not in the excerpt that is displayed.

#81014
Feb 07, 2014 9:42
Vote:
 

Hi,

how have you built your query? Here is an example on how the fields are being searched:

                    // will search in SearchTitle, SearchText, SearchSummary, SearchAttachment
                    .UnifiedSearchFor(q)

                    // will search in all fields
                    .UnifiedSearch().For(q)

                    // same as UnifiedSearchFor(), but with additional fields
                    .UnifiedSearch().For(q)
                    .InStandardFields()
                    .InField(x => x.SearchCategories)
                    .InField(x => ((ArticlePage)x).SecondaryBody)

    

#81019
Feb 07, 2014 10:31
Vote:
 

I guess i could specify fields explicitly. That would always work, but it would be better to exclude.

Like this (we also have some other filters and faceting):

ITypeSearch<ISearchContent> query = _epiFindClient
    .UnifiedSearchFor(searchParams.SearchString, currentLangauge);

EDIT: It seems like no matter what field I specify, it still get hits in the same fields.
#81039
Edited, Feb 07, 2014 12:50
Vote:
 

I would consider it a best practice to specify the fields, as there are a lot of information in the index, and in most cases you would not like to enable free text search on everything. I can see what you mean though, something like .NotInField(..) would be nice, but that would require some custom code.

However, since you are using .UnifiedSearchFor(..), you should by default only be searching in SearchTitle, SearchText, SearchSummary and SearchAttachment. At least that is the case with the latest version. 

If you still are getting hits on other properties then there must be something else triggering it. Have you implemented a wild card search or something similar?


#81043
Feb 07, 2014 13:10
Vote:
 
#81044
Feb 07, 2014 13:15
Vote:
 

This:

                ITypeSearch<ISearchContent> query = _epiFindClient.UnifiedSearch(currentLangauge)
                        .For(searchParams.SearchString);

    

Will search every field, as no fields have been specified.

Try a simple test, and see if that works: 

                ITypeSearch<ISearchContent> query = _epiFindClient.UnifiedSearch(currentLangauge)
                        .For(searchParams.SearchString)
                        .InField(x => x.SearchTitle)

    

#81045
Feb 07, 2014 13:26
Vote:
 

PS! The "SearchText" field will contain all properties that are marked as "Searchable". You could override this by creating a matching property on the page(s).

    public class ArticlePage : PageData
    {

        public string SearchText
        {
            get { return "Whatever " + this.SearchText(); }
        }

    }

    

 

#81657
Feb 23, 2014 11:08
* 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.