Skip to content
Swiftype Enterprise Node.js client
Branch: master
Clone or download
JasonStoltz Merge pull request #3 from elastic/synchronous-es-calls
Updated Indexing calls to new synchronous API
Latest commit acc61c3 May 3, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fixtures/api.swiftype.com-443 Updated calls to ES to new synchronous API May 1, 2019
lib Updated calls to ES to new synchronous API May 1, 2019
test Updated calls to ES to new synchronous API May 1, 2019
.gitignore Initial commit Jun 29, 2017
.nvmrc Updated calls to ES to new synchronous API May 1, 2019
LICENSE
README.md
logo-enterprise-search.png
package-lock.json Release 2.0.0 May 1, 2019
package.json

README.md

Elastic Enterprise Search Logo

A first-party Node.js client for Elastic Enterprise Search.

Contents


Getting started 🐣

With npm:

npm install swiftype-enterprise-node

or clone locally:

$ git clone git@github.com:swiftype/swiftype-enterprise-node.git
$ cd swiftype-enterprise-node
$ npm install

Usage

Create a new instance of the Swiftype Enterprise Client with your access token:

const SwiftypeEnterpriseClient = require('swiftype-enterprise-node')
const accessToken = '' // your access token
const swiftype = new SwiftypeEnterpriseClient(accessToken)

Indexing Documents

This example shows how to use the indexDocuments method:

const contentSourceKey = '' // your content source key
const documents = [
  {
    external_id: 1234,
    title: "5 Tips On Finding A Mentor",
    body: "The difference between a budding entrepreneur who merely shows promise and one who is already enjoying some success often comes down to mentoring.",
    url: "https://www.shopify.com/content/5-tips-on-finding-a-mentor"
  },
  {
    external_id: 1235,
    title: "How to Profit from Your Passions",
    body: "Want to know the secret to starting a successful business? Find a void and fill it.",
    url: "https://www.shopify.com/content/how-to-profit-from-your-passions"
  }
]

swiftype.indexDocuments(contentSourceKey, documents)
.then((results) => {
  // handle results
})
.catch((error) => {
  // handle error
})

Destroying Documents

const contentSourceKey = '' // your content source key
const documentExternalIds = [1234, 1235]

swiftype.destroyDocuments(contentSourceKey, documentExternalIds)
.then((destroyDocumentsResults) => {
  // handle destroy documents results
})
.catch((error) => {
  // handle error
})

Running tests

Run tests via npm:

$ npm test

FAQ 🔮

Where do I report issues with the client?

If something is not working as expected, please open an issue.

Contribute 🚀

We welcome contributors to the project. Before you begin, a couple notes...

License 📗

MIT © Elastic

Thank you to all the contributors!

You can’t perform that action at this time.