Skip to main content

ResultSet

Nosible API Client


Nosible API Client / ResultSet

Class: ResultSet

Defined in: src/search/resultSet.ts:37

A collection of search results with methods for filtering, analysis, and export.

ResultSet provides an interface for working with multiple search results, including full-text search, data analysis, and export to various formats.

Example

// Create from search results
const resultSet = ResultSet.fromResults(results, searchQuery, client);

// Search within results
const filtered = resultSet.findInResults('specific term');

// Analyze results
const analysis = resultSet.analyze(AnalyzeBy.SENTIMENT);

// Export to CSV
await resultSet.writeToCsv('results.csv');

Constructors

Constructor

new ResultSet(results): ResultSet

Defined in: src/search/resultSet.ts:47

Creates a new ResultSet instance

Parameters

results

Result[]

Array of Result objects to include in the set

Returns

ResultSet

Properties

results

results: Result[]

Defined in: src/search/resultSet.ts:39

Array of Result objects in this set


length

length: number

Defined in: src/search/resultSet.ts:40

Methods

fromFilePath()

static fromFilePath(filePath, client): Promise<ResultSet>

Defined in: src/search/resultSet.ts:68

Creates a ResultSet from a file path

Supports JSON and CSV file formats. The file is read and parsed into Result objects.

Parameters

filePath

string

Path to the file to import

client

NosibleClient

NosibleClient instance for creating Result objects

Returns

Promise<ResultSet>

Promise resolving to a new ResultSet

Throws

Error if file type is unsupported

Example

const resultSet = await ResultSet.fromFilePath('./data.json', client);

fromFile()

static fromFile(file, client): Promise<ResultSet>

Defined in: src/search/resultSet.ts:108

Creates a ResultSet from a File object (browser environment)

Supports JSON and CSV file formats. The file is read and parsed into Result objects.

Parameters

file

File

File object to import

client

NosibleClient

NosibleClient instance for creating Result objects

Returns

Promise<ResultSet>

Promise resolving to a new ResultSet

Throws

Error if file type is unsupported

Example

const fileInput = document.getElementById('file') as HTMLInputElement;
const file = fileInput.files[0];
const resultSet = await ResultSet.fromFile(file, client);

fromResults()

static fromResults(results, searchQuery, client): ResultSet

Defined in: src/search/resultSet.ts:141

Creates a ResultSet from search results

Converts SearchResponse objects and/or existing Result objects into a unified ResultSet.

Parameters

results

({ url_hash: string; url: string; netloc: string; published: string; visited: string; language: string; author: string; title: string; description: string; content: string; best_chunk: string; semantics: { origin_shard: number; chunks_total: number; chunks_matched: number; chunks_kept: number; similarity: number; bitstring: string; }; } | Result)[]

Array of SearchResponse or Result objects

searchQuery

The original search query used (needed for SearchResponse objects)

instruction

string = ...

question

string = ...

expansions

string[] = ...

brand_safety

null = ...

language

string | null = ...

continent

string | null = ...

region

string | null = ...

country

string | null = ...

sector

string | null = ...

industry_group

string | null = ...

industry

string | null = ...

sub_industry

string | null = ...

iab_tier_1

string | null = ...

iab_tier_2

string | null = ...

iab_tier_3

string | null = ...

iab_tier_4

string | null = ...

algorithm

string = ...

n_results

number = ...

n_contextify

number = ...

n_probes

number = ...

min_similarity

number = ...

pass_similarity

number = ...

must_exclude

string[] = ...

must_include

string[] = ...

shard_selector

string = ...

shard_reranker

string = ...

search_lang

string = ...

search_words

Record<string, number> = ...

search_intents

Record<string, any> = ...

companies

any[] = ...

client

NosibleClient

NosibleClient instance for creating Result objects

Returns

ResultSet

New ResultSet containing the processed results

Example

const resultSet = ResultSet.fromResults(searchResults, query, client);

join()

static join(resultSets): ResultSet

Defined in: src/search/resultSet.ts:171

Combines multiple ResultSet objects into a single ResultSet

Parameters

resultSets

ResultSet[]

Array of ResultSet objects to merge

Returns

ResultSet

New ResultSet containing all results from the input sets

Example

const combined = ResultSet.join([resultSet1, resultSet2, resultSet3]);

getResults()

getResults(): object[]

Defined in: src/search/resultSet.ts:182

Returns the raw data objects from all results

Returns

object[]

Array of result data objects


getFlattenResults()

getFlattenResults(): FlattenResult[]

Defined in: src/search/resultSet.ts:191

Returns flattened results with all nested data expanded

Returns

FlattenResult[]

Array of flattened result objects suitable for export


findInResults()

findInResults(query): Result[]

Defined in: src/search/resultSet.ts:209

Performs full-text search within the results using Lunr.js

Creates a search index from result content and returns matching results. Useful for filtering large result sets based on specific terms.

Parameters

query

string

Search query string

Returns

Result[]

Array of Result objects matching the query

Example

const importantResults = resultSet.findInResults('urgent OR critical');

analyze()

analyze(by): AnalyzeResult

Defined in: src/search/resultSet.ts:258

Analyzes results using various metrics and groupings

Parameters

by

AnalyzeBy

Analysis type (sentiment, entities, topics, etc.)

Returns

AnalyzeResult

Analysis result containing insights and statistics

Example

const sentimentAnalysis = resultSet.analyze(AnalyzeBy.SENTIMENT);
const entityAnalysis = resultSet.analyze(AnalyzeBy.ENTITIES);

toPolars()

toPolars(): Promise<DataFrame<any>>

Defined in: src/search/resultSet.ts:277

Converts results to a Polars DataFrame (Node.js only)

Uses flattened results for tabular data structure. Not available in browser environments.

Returns

Promise<DataFrame<any>>

Promise resolving to a Polars DataFrame

Throws

Error if called in browser environment

Example

const df = await resultSet.toPolars();
const filtered = df.filter(pl.col('sentiment').gt(0.5));

writeToCsv()

writeToCsv(fileName): Promise<void>

Defined in: src/search/resultSet.ts:300

Exports results to a CSV file

Uses flattened results for tabular format. Works in both Node.js and browser environments.

Parameters

fileName

string

Name of the CSV file to create

Returns

Promise<void>

Example

await resultSet.writeToCsv('search-results.csv');

writeToParquet()

writeToParquet(fileName): Promise<void>

Defined in: src/search/resultSet.ts:319

Exports results to a Parquet file (Node.js only)

Creates an efficient columnar storage format using Polars. Not available in browser environments.

Parameters

fileName

string

Name of the Parquet file to create

Returns

Promise<void>

Throws

Error if called in browser environment

Example

await resultSet.writeToParquet('results.parquet');

writeToIpc()

writeToIpc(fileName): Promise<void>

Defined in: src/search/resultSet.ts:344

Exports results to an IPC file (Node.js only)

Creates an Arrow IPC format file using Polars. Not available in browser environments.

Parameters

fileName

string

Name of the IPC file to create

Returns

Promise<void>

Throws

Error if called in browser environment

Example

await resultSet.writeToIpc('results.arrow');

writeToJson()

writeToJson(fileName): Promise<void>

Defined in: src/search/resultSet.ts:367

Exports results to a JSON file

Uses the raw result data format. Works in both Node.js and browser environments.

Parameters

fileName

string

Name of the JSON file to create

Returns

Promise<void>

Example

await resultSet.writeToJson('results.json');

writeToNdjson()

writeToNdjson(fileName): Promise<void>

Defined in: src/search/resultSet.ts:384

Exports results to a newline-delimited JSON (NDJSON) file

Uses flattened results with each result on a separate line. Works in both Node.js and browser environments.

Parameters

fileName

string

Name of the NDJSON file to create

Returns

Promise<void>

Example

await resultSet.writeToNdjson('results.ndjson');