You are here: C++ Support Classes > dtSearch Namespace > Classes > DSearchReportJob Class
Close
dtSearch Text Retrieval Engine Programmer's Reference
DSearchReportJob Class

Describes a search report to be prepared from some or all of the items in a DSearchResults set.

File: dtsfc.h 

Namespace: dtSearch 

Syntax
C++
class DSearchReportJob : public DOutputBase;
Show:
No members matching the current filter
Show:
No members matching the current filter
Show:
No members matching the current filter
Show:
No members matching the current filter

To generate a search report, 

(1) Start with a dtsSearchResults object representing the results of a search. 

(2) Declare a DSearchReportJob, passing the dtsSearchResults to the constructor 

(3) Select the items to include in the search report using the Select*() methods in DSearchReportJob 

(4) Specify the amount of context to include using SetContextWords() or SetContextParagraphs() 

(5) Set the output format for the report 

(6) Call Execute() to generate the report

Format

A search report lists the hits found in one or more documents, with each hit surrounded by a specified amount of context. Each block of context starts with a contextHeader and ends with the contextFooter. Contiguous or overlapping blocks of context will be combined. The amount of context included in the report can be specified by words or by paragraphs. 

Each block of context is constructed as follows:

[ContextHeader] ...text... [BeforeHit] hit [AfterHit] ...text... [ContextFooter]

 

The report as a whole is constructed as follows:

[Header] [FileHeader] [ContextHeader] ...text... [BeforeHit] hit [AfterHit] ...text... [ContextFooter] [ContextHeader] ...text... [BeforeHit] hit [AfterHit] ...text... [ContextFooter] ... more blocks of context, if present [FileFooter] ... more files ... [Footer]

 

Use the following symbols to insert file information into the FileHeader and FileFooter:

Symbol
Meaning
Filename
The name of the file (without path information). For PDF and HTML files, this will be the Title.
Location
The location of the file
Fullname
The path and filename of the file.
Size
File size in bytes
SizeK
File size in kilobytes
Date
Modification date of the file when indexed
Hits
Number of hits in the file
Title
The first 80 characters of the file
The docId of the file
Type
The file type (Microsoft Word, PDF, HTML, etc.)
Ordinal
The 1-based ordinal of this item in the SearchResults from which it was generated
IndexRetrievedFrom
The index where the file was found

Use %% around each symbol, like this: %%FullName%% 

Use the following symbols to insert context information in the contextHeader, which appears in front of each block of context:

Symbol
Meaning
Page
Page number where the hit occurs
Paragraph
Paragraph number where the hit occurs (relative to the start of the page)
Word
Word offset of the block of context from the beginning of the file.
FirstHit
Word offset of the first hit in the block of context.
// Assume m_pResults is a pointer to dtsSearchResults DSearchReportJob reportJob(*m_pResults); // Request exactly 10 words of context around each hit reportJob.SetContextWords(10, true); // Specify which items in search results to include reportJob.SelectRange(firstItemToInclude, lastItemToInclude); // Highlight hits in bold, with a line between each block of context reportJob.SetOutputFormat(it_Html); reportJob.BeforeHit.setU8("<b>"); reportJob.AfterHit.setU8("</b>"); reportJob.ContextHeader = "<hr>"; // Generate output to a string limited to 512 bytes reportJob.SetOutputToString(512); // Request at most two blocks of context for each document included in the report reportJob.SetMaxContextBlocks(2); // Use cached text in the index, if present reportJob.SetFlag(dtsReportGetFromCache); // Generate the report reportJob.Execute();
dtSearch__DSearchReportJobdtSearch__DSearchReportJobdtSearch__DSearchReportJob
Copyright (c) 1995-2021 dtSearch Corp. All rights reserved.