Results

Search returns a Result object containing ranked document keys and scores — not full JSON. Retrieve full documents with GetJsonDataOfKey.

Basic Usage

csharp
var result = engine.Search(query);
if (result != null)
{
    foreach (var rec in result.Records)
    {
        long key   = rec.DocumentKey;
        int  score = rec.Score;
        string json = engine.GetJsonDataOfKey(key);
        Console.WriteLine(
quot;[{score}] {json}"); } }

Result Properties

PropertyTypeDescription
Records
ScoreEntry16[]
Ranked documents. Each has DocumentKey (long) and Score (ushort, 0–65535)
Facets
Dictionary<string, KeyValuePair<string, int>[]>?
Field → value/count pairs, keyed on the value as stored. null when EnableFacets is false
TruncationIndex
int
Index in Records of the last result that reached the coverage bar. -1 when none did: on a text query with coverage on, that means every result is a pattern match (or there are none, without IncludePatternMatches). Also -1 when coverage did not run
TruncationScore
ushort
Score at the truncation point
DidTimeOut
bool
true if scoring was cut short by TimeOutLimitMilliseconds

Facet Counts and Filter Counts

A facet keys on the value as stored, so a dataset that spells a value both ways, Fiction and FICTION, lists it twice. A value filter compares case-insensitively unless you build it with isCaseSensitive: true, so clicking either entry returns the documents of both spellings. A facet count therefore equals a filter count only for a case-sensitive filter, which gives up the per-field posting index and loads by scanning: same answers, more work.

A document whose array holds the same value twice counts once, so an array field's facet counts agree with its own filter.

Working with Facets

csharp
query.EnableFacets = true;
var result = engine.Search(query);

if (result.Facets != null)
{
    foreach (var facet in result.Facets)
    {
        Console.WriteLine(
quot;{facet.Key}:"); foreach (var bucket in facet.Value) Console.WriteLine(
quot; {bucket.Key} ({bucket.Value})"); } }

Retrieving Full Documents

csharp
// Single document
string json = engine.GetJsonDataOfKey(result.Records[0].DocumentKey);

// Multiple documents
var keys = result.Records.Select(r => r.DocumentKey);
foreach (var json in engine.GetJsonDataOfKeys(keys))
    Console.WriteLine(json);

ScoreEntry16

PropertyTypeDescription
DocumentKey
long
Unique key identifying the document
Score
ushort
Relevance score 0–65535. Higher is more relevant

Constructors

csharp
Result()

Initializes a default empty result.

Properties

NameTypeAccessDescription
DidTimeOut
bool
get/set
True when the search could not be served, rather than served and found nothing. Two situations set it:
Reason
ProcessError
get/set
RecordsWhy this search returned nothing, when the cause was the request or this engine rather than an absence of matches. Null on a normal search, including one that legitimately matched nothing — an emptywith a null Reason means "no matches", which is the distinction a caller could not previously make.
SystemState
SystemState
get/set
SystemStatusThe engine's state at the moment this search ran, which is what a caller needs to decide whether to retry:orwill pass, a bad request will not. A snapshot of the one field worth copying — the rest ofis engine-wide and describes the engine over time rather than this request, so reading it per search would report other callers' conditions as if they were yours.
Facets
Dictionary<string, KeyValuePair<string, int>[]>
get/set
Facet counts per facetable field, keyed by field name. Null when no facetable fields are configured.
Records
ScoreEntry16[]
get/set
Ranked search hits in descending score order.
TruncationIndex
int
get/set
Internal index at which results were truncated to the requested top-k limit.
TruncationScore
UInt16
get/set
Score threshold at which results were truncated.

Methods

MakeEmptyResult

Returns an empty result, optionally marked as having timed out.

csharp
static Result MakeEmptyResult(bool timedOut = false, ProcessError reason = null, SystemState systemState = Created)
  • bool timedOut — DidTimeOutSets— the search could not be served.
  • ProcessError reason — ReasonSets; null for a transient failure or a genuine miss.
  • SystemState systemState — SystemStateSets— the engine state when the search ran. Defaults torather than: a caller who omits it has not established that the engine was ready, and defaulting to the optimistic value would put an unverified claim in the result.

Returns: Result

ScoreEntry16struct

A result's document key and score, the score in the range 0..65535.

NameTypeDescription
DocumentKey
long
Id, key or internal index of a document.
Score
UInt16
The 16-bit score value of the document.