
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
@elastic/site-search-node
Advanced tools
A first-party Node client for the Elastic Site Search API.
With npm:
npm install @elastic/site-search-node
or clone locally:
$ git clone git@github.com:elastic/site-search-node.git
$ cd site-search-node
$ npm install
Create a new instance of the client with your api key:
var SiteSearchClient = require("@elastic/site-search-node");
var client = new SiteSearchClient({
apiKey: "yourApiKey"
});
Search for cats
on the engine my-engine
with filters and facets:
client.search(
{
engine: "my-engine",
q: "cats",
filters: {
page: {
enumField: "theFilter"
}
},
facets: {
page: ["enumField", "anotherField"]
}
},
function(err, res) {
console.log(res);
}
);
Autocomplete suggestion for cat
on the engine my-engine
with filters:
client.suggest(
{
engine: "my-engine",
q: "cat",
filters: {
page: {
enumField: "theFilter"
}
}
},
function(err, res) {
console.log(res);
}
);
Log clickthrough for cat
on the engine my-engine
for the documentType page
:
client.click(
{
engine: "my-engine",
q: "cat",
id: "the-document-id",
documentType: "page"
},
function(err, res) {
console.log(res);
}
);
Create a new document:
client.documents.create(
{
engine: "my-engine",
documentType: "books",
document: {
external_id: "1",
fields: [
{ name: "title", value: "The Great Gatsby", type: "string" },
{ name: "author", value: "F. Scott Fitzgerald", type: "string" },
{ name: "genre", value: "fiction", type: "enum" }
]
}
},
function(err, res) {
console.log(res);
}
);
Fetch all of your engines:
client.engines.list(function(err, res) {
console.log(res);
});
Fetch a single engine:
client.engines.get(
{
engine: "my-engine"
},
function(err, res) {
console.log(res);
}
);
Fetch all of the document types in the engine my-engine
client.documentTypes.list(
{
engine: "my-engine"
},
function(err, res) {
console.log(res);
}
);
Fetch the document type books
in the engine my-engine
client.documentTypes.get(
{
engine: "my-engine",
documentType: "books"
},
function(err, res) {
console.log(res);
}
);
Create the document type books
in the engine my-engine
client.documentTypes.create(
{
engine: "my-engine",
document_type: { name: "books" }
},
function(err, res) {
console.log(res);
}
);
Check out the tests for more examples!
$ npm test
The tests use stubbed HTTP interactions that are recorded with the node-replay module. By default, HTTP interactions are not allowed when running the tests.
The tests can also use environment variables so that you can create new replays against your own account. Don't forget to change the "authorization" header in the replay files to not give away your api key.
If something is not working as expected, please open an issue.
Your best bet is to read the documentation.
You can checkout the Elastic Site Search community discuss forums.
We welcome contributors to the project. Before you begin, a couple notes...
Thank you to all the contributors!
FAQs
Elastic Site Search API client for Node.js
The npm package @elastic/site-search-node receives a total of 1,542 weekly downloads. As such, @elastic/site-search-node popularity was classified as popular.
We found that @elastic/site-search-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 62 open source maintainers 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.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.