
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
indexden-client
Advanced tools
Node.js promisified client for indexden.com. Powered by Bluebird and Request-Promise.
npm install indexden-client
let Indexden = require('indexden-client');
// Create client
let client = new Indexden.Client(
"http://my-indexden-server.com"
);
// Get metadata about all registered indexes
client
.getIndexesMetadata()
.then(data => console.log(data));
Since typings for typescript are bundled with this package, you can use it directly with Typescript:
import * as Indexden from 'indexden-client';
// Create client
let client: Indexden.Client = new Indexden.Client(
"http://my-indexden-server.com"
);
// Get metadata about all registered indexes
client
.getIndexesMetadata()
.then(data: Indexden.Indexes.MetadataMap => console.log(data));
Please refer to the offcial API for all return types and parameters, unless their shape is made explicit here.
When not precised, all methods will return Promise<void>
.
GET /v1/indexes
, GET /v1/indexes/name
This will return metadata for all known indexes, or to the one specified by indexName.
If indexName is not precised, the result will be a MetadataMap, which is simply a metadata's map having the index's name as key.
PUT /v1/indexes
This will create or update the index indexName.
To enable public search, you must set the second parameter to true. false by default.
DELETE /v1/indexes
This will delete the index indexName.
PUT /v1/indexes/docs
This will index or update an indexed document to the given index indexName. Parameter docs can be a single doc or an array of docs, with the following shape:
interface Doc {
/**
* The document's ID.
*/
docid: string;
/**
* A map from field name to field value.
* The sum of the length of each field value MUST not be greater than 100kbytes.
*/
fields: {
[key: string]: string;
};
/**
* A map from the var number to float.
*/
variables?: {
[key: number]: number;
};
/**
* A map from the category name to its value.
* By default, the document is indexed under the key 'text'.
*/
categories?: {
[key: string]: string;
};
}
DELETE /v1/indexes/docs
This will delete documents specified by docIds in the index indexName.
GET /v1/indexes/name/search
This will perform a search in the index indexName. The options parameter must have the following shape:
interface Option {
/**
* The query to be performed.
*/
q: string;
/**
* For paging, the first position to return.
*/
start?: number;
/**
* How many results to return (default: 10).
*/
len?: number;
/**
* The number of the scoring function to use (default: 0).
*/
"function"?: number;
/**
* Comma-separated list of fields to fetch.
* '*' returns all present fields for each document.
*/
fetch?: string;
/**
* 'true' returns all variables for each document as variable_<N> (unset vars return 0).
*/
fetch_variables?: boolean;
/**
* 'true' returns all categories for each document as category_<NAME>.
*/
fetch_categories?: boolean;
/**
* Comma-separated list of fields to snippet.
*/
snippet?: string;
/**
* Value of the query variable <N>.
*/
"var"?: { [key: number]: string; };
/**
*A json map from category name to a list of the admitted values for those categories.
*/
category_filters?: {
[key: string]: string[];
}[];
/**
* Comma-separated list of ranges to filter the values of variable <N>.
* Each range is expressed as BOTTOM:TOP,
* where any of both limits can be replaced by an * symbol to indicate it should be ignored.
*/
filter_docvar?: { [key: number]: string; };
/**
* Comma-separated list of ranges to filter the values of function <N>.
* Each range is expressed as BOTTOM:TOP,
* where any of both limits can be replaced by an * symbol to indicate it should be ignored.
*/
filter_function?: { [key: number]: string; };
/**
* 'true' - global search inside whole index (default false).
*/
match_any_field?: boolean;
}
The result will have the following shape:
interface Result {
/**
* The total number of matches for the query.
*/
matches: number | string;
/**
* A map from category name to a values count map.
*/
facets: { [key: string]: string; };
/**
* A list of objects with the "docid" field.
*/
results: Match[];
/**
* The time it took to search in seconds.
*/
search_time: number;
}
/**
* A match from a query.
* << Search results will contain the document identifiers provided at indexing time.
* If fetch and snippet fields were specified,
* the field's content or a snippet of the content can be returned along with the identifiers. >>
*/
interface Match {
/**
* The ID under which the doc is registered.
*/
docid: string;
/**
* Query specific document relevance score.
*/
query_relevance_score?: number;
/**
* "variable_<N>": variable value, from 0 to N.
*/
variables?: {[key: string]: any};
/**
* "category_<NAME>": category value for the NAME document category / facet.
*/
category?: {[key: string]: any};
}
DELETE /v1/indexes/name/search
Same as the previous version but will remove documents.
PUT /v1/indexes/name/docs/variables
This will create or updates variables for the given document, for the index indexName.
The options parameter must have this shape:
interface Variables {
/**
* The document's ID.
*/
docid: string;
/**
* A map from the var number to float.
*/
variables: {
[key: number]: number;
};
}
PUT /v1/indexes/name/docs/categories
This will create or updates categories for the given document, for the index indexName.
The options parameter must have this shape:
interface Categories {
/**
* The document's ID.
*/
docid: string;
/**
* A map from the categories' names to the values for this document.
*/
categories: {
[key: string]: string;
};
}
GET /v1/indexes/name/functions
This will gather all known scoring functions for the index indexName.
The result will have the following shape:
interface FunctionMap {
/**
* A map to the function formula
* from the number identifying the function.
*/
[key: number]: string;
}
PUT /v1/indexes/name/functions/num
This will create or update the scoring functions identified by the number functionId and defined by the formula f for the index indexName.
DELETE /v1/indexes/name/functions/num
This will remove the scoring functions identified by the number functionId from the index indexName.
PUT /v1/indexes/name/promote
This will promote the document provided by options in the index indexName for a specific query.
The options parameter must have the following shape:
interface Promoted {
/**
* The document's ID.
*/
docid: string;
/**
* The query to in which to promote it.
*/
query: string;
}
GET /v1/indexes/name/autocomplete
This will suggest search for the provided query for the index indexName.
BEWARE, JSONP is NOT supported by this client.
The options parameter must have the following shape:
interface Autocomplete {
/**
* The query to be performed.
*/
query: string;
/**
* The field to take suggestions from.
* By default, 'text' field will be chosen.
*/
field?: string;
}
The result will have the following shape:
interface Suggestions {
/**
* JSON array with query matches.
*/
suggestions: string[];
/**
* Requested query parameter (may be normalized).
*/
query: string;
}
FAQs
Node.js client for http://www.indexden.com
We found that indexden-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.