Socket
Socket
Sign inDemoInstall

@elastic/site-search-node

Package Overview
Dependencies
49
Maintainers
62
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

lib/documents.js

@@ -28,3 +28,3 @@ 'use strict';

batchCreate: function(params, documents, batchSize, doneCallback){
if (!batchSize) {
if (!doneCallback) {
doneCallback = batchSize

@@ -31,0 +31,0 @@ batchSize = 10

{
"name": "@elastic/site-search-node",
"version": "1.0.0",
"version": "1.0.1",
"description": "Elastic Site Search API client for Node.js",

@@ -8,3 +8,3 @@ "homepage": "https://github.com/elastic/site-search-node",

"author": "Mike Chlipala",
"license": "Apache 2.0",
"license": "Apache-2.0",
"repository": {

@@ -11,0 +11,0 @@ "type": "git",

@@ -9,23 +9,26 @@ <p align="center"><img src="https://github.com/elastic/site-search-node/blob/master/logo-site-search.png?raw=true" alt="Elastic Site Search Logo"></p>

+ [Getting started](#getting-started-)
+ [Usage](#usage)
+ [Running tests](#running-tests)
+ [FAQ](#faq-)
+ [Contribute](#contribute-)
+ [License](#license-)
- [Getting started](#getting-started-)
- [Usage](#usage)
- [Running tests](#running-tests)
- [FAQ](#faq-)
- [Contribute](#contribute-)
- [License](#license-)
***
---
## Getting started 🐣
With npm:
npm install @elastic/site-search-node
```shell
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
```shell
$ git clone git@github.com:elastic/site-search-node.git
$ cd site-search-node
$ npm install
```

@@ -36,6 +39,8 @@ ## Usage

var SiteSearchClient = require('@elastic/site-search-node')
var client = new SiteSearchClient({
apiKey: 'yourApiKey'
})
```javascript
var SiteSearchClient = require("@elastic/site-search-node");
var client = new SiteSearchClient({
apiKey: "yourApiKey"
});
```

@@ -46,16 +51,21 @@ ### Searching

client.search({
engine: 'my-engine',
q: 'cats',
filters: {
page: {
'enumField': 'theFilter'
}
},
facets: {
page: ['enumField', 'anotherField']
```javascript
client.search(
{
engine: "my-engine",
q: "cats",
filters: {
page: {
enumField: "theFilter"
}
}, function(err, res) {
console.log(res)
})
},
facets: {
page: ["enumField", "anotherField"]
}
},
function(err, res) {
console.log(res);
}
);
```

@@ -66,13 +76,18 @@ ### Autocomplete

client.suggest({
engine: 'my-engine',
q: 'cat',
filters: {
page: {
'enumField': 'theFilter'
}
```javascript
client.suggest(
{
engine: "my-engine",
q: "cat",
filters: {
page: {
enumField: "theFilter"
}
}, function(err, res) {
console.log(res)
})
}
},
function(err, res) {
console.log(res);
}
);
```

@@ -83,10 +98,15 @@ ### Click

client.click({
engine: 'my-engine',
q: 'cat',
id: 'the-document-id',
documentType: 'page'
}, function(err, res) {
console.log(res)
})
```javascript
client.click(
{
engine: "my-engine",
q: "cat",
id: "the-document-id",
documentType: "page"
},
function(err, res) {
console.log(res);
}
);
```

@@ -97,18 +117,22 @@ ### Documents

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)
})
```javascript
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);
}
);
```
### Engines

@@ -118,13 +142,20 @@

client.engines.list(function(err, res) {
console.log(res)
})
```javascript
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)
})
```javascript
client.engines.get(
{
engine: "my-engine"
},
function(err, res) {
console.log(res);
}
);
```

@@ -135,25 +166,40 @@ ### Document Types

client.documentTypes.list({
engine: 'my-engine'
}, function(err, res) {
console.log(res)
})
```javascript
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)
})
```javascript
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)
})
```javascript
client.documentTypes.create(
{
engine: "my-engine",
document_type: { name: "books" }
},
function(err, res) {
console.log(res);
}
);
```

@@ -164,3 +210,5 @@ Check out the tests for more examples!

$ npm test
```shell
$ npm test
```

@@ -171,7 +219,7 @@ The tests use stubbed HTTP interactions that are recorded with the [node-replay](https://github.com/assaf/node-replay) module. By default, HTTP interactions are not allowed when running the tests.

* SITE_SEARCH_TEST_MY_ENGINE = the slug for your 'my-engine' in the tests
* SITE_SEARCH_TEST_BOOKSTORE_ENGINE = the slug for your 'bookstore' in the tests
* SITE_SEARCH_TEST_TEMPORARY_ENGINE = the slug for your 'temporary' in the tests
* SITE_SEARCH_TEST_API_KEY = your api key in the tests
* REPLAY = 'record' to record new replay files
- SITE_SEARCH_TEST_MY_ENGINE = the slug for your 'my-engine' in the tests
- SITE_SEARCH_TEST_BOOKSTORE_ENGINE = the slug for your 'bookstore' in the tests
- SITE_SEARCH_TEST_TEMPORARY_ENGINE = the slug for your 'temporary' in the tests
- SITE_SEARCH_TEST_API_KEY = your api key in the tests
- REPLAY = 'record' to record new replay files

@@ -196,4 +244,4 @@ ## FAQ 🔮

+ Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/site-search-node/issues).
+ Please write simple code and concise documentation, when appropriate.
- Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/site-search-node/issues).
- Please write simple code and concise documentation, when appropriate.

@@ -200,0 +248,0 @@ ## License 📗

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc