SearchSet
Nosible API Client / SearchSet
Class: SearchSet
Defined in: src/search/searchSet.ts:57
Core classes for interacting with the Nosible AI Search API.
- NosibleClient: Main client class for all API operations
- Search: Represents a single search configuration with parameters
- SearchSet: Collection of Search instances for batch operations
- ResultSet: Collection of search results with analysis and export methods
- WebPageData: Structured data from scraped web pages
- TopicTrend: Analysis of topic popularity trends over time
Constructors
Constructor
new SearchSet(
params):SearchSet
Defined in: src/search/searchSet.ts:61
Parameters
params
Search[] | { searches: Search[]; }
Returns
SearchSet
Properties
searches
searches:
Search[] =[]
Defined in: src/search/searchSet.ts:58
index
index:
number
Defined in: src/search/searchSet.ts:59
Methods
fromFilePath()
staticfromFilePath(filePath):Promise<SearchSet>
Defined in: src/search/searchSet.ts:93
Creates a SearchSet from a JSON or CSV file asynchronously.
The file should contain an array of search objects that conform to the Search parameter schema. JSON files should contain the raw search objects, while CSV files should have columns matching the Search parameter names.
Parameters
filePath
string
Path to the JSON or CSV file containing search definitions
Returns
Promise<SearchSet>
Promise that resolves to a new SearchSet instance
Example
// Load searches from a JSON file
const searchSet = await SearchSet.fromFilePath("./searches.json");
// Load searches from a CSV file
const searchSetFromCsv = await SearchSet.fromFilePath("./searches.csv");
Throws
Error if the file type is not supported (must be .json or .csv)
fromFile()
staticfromFile(file):Promise<SearchSet>
Defined in: src/search/searchSet.ts:128
Creates a SearchSet from a File object asynchronously.
This method is useful in browser environments when working with file uploads or drag-and-drop functionality. The file should contain search definitions in JSON or CSV format.
Parameters
file
File
File object to read from (must be JSON or CSV)
Returns
Promise<SearchSet>
Promise that resolves to a new SearchSet instance
Example
// Handle file upload in a browser
const fileInput = document.getElementById('file-input') as HTMLInputElement;
const file = fileInput.files[0];
if (file) {
const searchSet = await SearchSet.fromFile(file);
const results = await client.fastSearches(searchSet);
}
Throws
Error if the file type is not supported (must be .json or .csv)
next()
next():
Search|null
Defined in: src/search/searchSet.ts:156
Returns the next search in the set and advances the internal iterator.
This method allows sequential iteration through the search set. The index starts at -1 and increments with each call.
Returns
Search | null
The next Search object in the set, or null if there are no more searches
Example
const searchSet = new SearchSet([search1, search2, search3]);
let search = searchSet.next(); // Returns search1
search = searchSet.next(); // Returns search2
search = searchSet.next(); // Returns search3
search = searchSet.next(); // Returns null (end of set)
add()
add(
search):void
Defined in: src/search/searchSet.ts:179
Adds a new search to the end of the search set.
Parameters
search
The Search object to add to the set
Returns
void
Example
const searchSet = new SearchSet([search1, search2]);
const newSearch = new Search({ question: "blockchain technology", nResults: 10 });
searchSet.add(newSearch);
console.log(searchSet.searches.length); // 3
remove()
remove(
index):void
Defined in: src/search/searchSet.ts:198
Removes a search from the set at the specified index.
Parameters
index
number
The zero-based index of the search to remove
Returns
void
Example
const searchSet = new SearchSet([search1, search2, search3]);
searchSet.remove(1); // Removes search2
console.log(searchSet.searches.length); // 2
Throws
Error if the index is out of bounds
toPolars()
toPolars():
Promise<DataFrame<any>>
Defined in: src/search/searchSet.ts:219
Converts the search set to a Polars DataFrame.
This method is only available in Node.js environments and requires the 'nodejs-polars' package to be installed. Each search becomes a row in the DataFrame.
Returns
Promise<DataFrame<any>>
Promise that resolves to a Polars DataFrame
Example
// Only works in Node.js environment
const df = await searchSet.toPolars();
console.log(df.shape); // [n_searches, n_columns]
Throws
Error if called in a browser environment
writeToCsv()
writeToCsv(
fileName):Promise<void>
Defined in: src/search/searchSet.ts:242
Exports the search set to a CSV file.
Each search in the set becomes a row in the CSV file with columns corresponding to the search parameters.
Parameters
fileName
string
The name of the CSV file to create
Returns
Promise<void>
Example
await searchSet.writeToCsv("my-searches.csv");
writeToJson()
writeToJson(
fileName):Promise<void>
Defined in: src/search/searchSet.ts:259
Exports the search set to a JSON file.
The entire search set is serialized as a JSON array, with each search object containing all its parameters.
Parameters
fileName
string
The name of the JSON file to create
Returns
Promise<void>
Example
await searchSet.writeToJson("my-searches.json");
writeToNdjson()
writeToNdjson(
fileName):Promise<void>
Defined in: src/search/searchSet.ts:276
Exports the search set to a Newline Delimited JSON (NDJSON) file.
Each search is written as a separate JSON object on its own line, which is useful for streaming large datasets or incremental processing.
Parameters
fileName
string
The name of the NDJSON file to create
Returns
Promise<void>
Example
await searchSet.writeToNdjson("my-searches.ndjson");