I have tried this, but it did not work (It still searches for SearchHitURL).
client.Conventions.ForInstancesOf<ISearchContent>()
.ExcludeField(page => page.SearchHitUrl);
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?
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.
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)?
InAllField() does not include every field there is.
It adds querying on one specific special purpose field called the _all field. This field is not analzyed for stemming and is also in theory bad for relevance.
"The _all field is a special catch-all field which concatenates the values of all of the other fields into one big string, using space as a delimiter, which is then analyzed and indexed, but not stored. This means that it can be searched, but not retrieved."
We don't really recommend using .InAllField().
We recommend specifying those fields you want to query on with .InField().
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,
Can't we have something similar to below,