We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Limit the contents in the .html file created to Highlight search results

Hi,

I need to ask either we can limit, hide or remove the text/contents/metadata fields showing in the .html file which is created when we want to highlight search results. Like the image is attached of the .html file which contains information of the document like complete directory URL, filename, format family etc.

image.png (11.9 KB)

My concern is can I hide or remove the filename or URL from the .html file?

Thank you.

This feature is not supported by the API. However, we have opened the following new ticket(s) in our internal issue tracking system. We’ll further investigate this scenario according to the terms mentioned in Free Support Policies.

Issue ID(s): SEARCHNET-2797

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@Hamdah

You can filter fields by name if you use the StructureOutputAdapter class.

//C# code
var result = index.Search("word");
Console.WriteLine("Found: " + result.DocumentCount);

var outputAdapter = new StructureOutputAdapter(OutputFormat.Html);
var highlighter = new DocumentHighlighter(outputAdapter);

index.Highlight(result.GetFoundDocument(0), highlighter);

using (var sw = File.CreateText(@"../../../../Output.html"))
{
    var fields = outputAdapter.GetResult();
    // Take only the fields you need
    for (int i = 0; i < fields.Length; i++)
    {
        var field = fields[i];
        sw.WriteLine("<h2>" + field.Name + "</h2>");
        sw.WriteLine(field.Value);
    }
}