Reputation: 570
I have a need to create a specific index to perform a search on a particular field from an inherited template. That part of creating the index and returning matching results is fairly straight forward.
The issue I am having is that when doing a search that would not be an intended match for the field, I am getting false results because the Lucene.NET document field '_name' contains the search criteria and is considering that a match.
I am using the Advanced Database Crawler, and have gone as far in the investigation to exclude almost every field possible until I used Luke to uncover the problem.
How can I exclude document fields such as '_name' from being searchable to exclude this situation from returning the results not intended?
Upvotes: 2
Views: 455
Reputation: 1926
Lucene documents have a RemoveField method. In your custom DatabaseCrawler you could normally remove fields from the document:
public class MyCustomCrawler : Sitecore.Search.Crawlers.DatabaseCrawler
{
protected override void AddAllFields(Lucene.Net.Documents.Document document, Sitecore.Data.Items.Item item, bool versionSpecific)
{
document.RemoveField("SomeFieldName");
...
}
}
In this case the fields are added after "AddAllFields'. It happens in "AddSpecialFields", so you can do something like this:
protected override void AddSpecialFields(Document document, Sitecore.Data.Items.Item item)
{
// Do nothing, don't call base.AddSpecialFields
}
Upvotes: 0