Any way to exclude certain fields from search?

Vote:
 

When having the '.InAllField()' search, how can we exclude certain fields from searching? I always think it's better to have the blacklist approach (Having 'InAllField()'' and then excluding certain fields) than the whitelist approach (Describing which fields to be searched one by one). Because I do not like to define 100s of fields (in the InFields) if I have to only exclude 2 fields.

My implementation is as below,

var result = client.Search<SamplePage>(GetLanguage(LanguageID))
                .For(Query, SearchHelper.QueryStringQueryAction)
                .InFields(x => x.Name, x => x.Content )
                .InAllField()
                // Blah blah
                .GetResult();

Can't we have something similar to below,

var result = client.Search<SamplePage>(GetLanguage(LanguageID))
                .For(Query, SearchHelper.QueryStringQueryAction)
                .InFields(x => x.Name, x => x.Content )
                .InAllField()
                .ExcludeFields(x => x.Field1, x => x.Field2 )// <---Like this 
                // Blah blah   
                .GetResult();
#218464
Mar 13, 2020 10:00
Vote:
 

Yes I believe we have ExcludeField()

#218467
Mar 13, 2020 10:14
Vote:
 

I have tried this, but it did not work (It still searches for SearchHitURL). 

client.Conventions.ForInstancesOf<ISearchContent>()
                          .ExcludeField(page => page.SearchHitUrl);
#218471
Mar 13, 2020 10:52
Vote:
 

Wait, I mixed things up. InFields let you search in those indexed fields. ExcludeField excludes the field  from being indexed. How can you still search by SearchHitUrl if you don't index it?

#218472
Mar 13, 2020 10:57
Senura Dissanayake - Mar 13, 2020 11:43
My bad, I forgot to state that there is another field contain the same value. However, I do not want to remove the field from being index. I need to exclude that field when searching.
Vote:
 

Regardless I think this is a reasonable request. I will fire a bug for FInd team to look into it, but I don't think it will be added anytime soon.

#218473
Mar 13, 2020 11:00
Vote:
 

Thanks. Meanwhile, is there any alternative way I could achieve that? Or else I have to declare every field that needs to be searched (Whitelist approach)?

#218479
Mar 13, 2020 11:45
* 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.