Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/algolia/algolia-index-transform
Transform an index using map, reduce or filter and push to a brand new index.
https://github.com/algolia/algolia-index-transform
Last synced: 13 days ago
JSON representation
Transform an index using map, reduce or filter and push to a brand new index.
- Host: GitHub
- URL: https://github.com/algolia/algolia-index-transform
- Owner: algolia
- Created: 2017-11-24T09:29:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T09:54:41.000Z (over 1 year ago)
- Last Synced: 2024-11-04T11:04:08.058Z (16 days ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Algolia Index Transform
A selection of methods to transform an index using `map`, `reduce` or `filter`.
and push to a brand new index.### Install
##### Node Using NPM
`npm install algolia-index-transform`
##### Node Using yarn
`yarn add algolia-index-transform`
### Set Up
Once installed, you will need to initalize the Algolia Index Transform as below.
Each property is required.```js
const AlgoliaIndexTransform = require('algolia-index-transform');const algoliaIndexTransform = new AlgoliaIndexTransform({
sourceApplicationID: 'xxxxxxxxxx',
sourceApiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
sourceIndexName: 'an existing index',
destinationApplicationID: 'xxxxxxxxxx',
destinationApiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
destinationIndexName: 'a new index',
limit: 20000,
requestOptions: {
attributesToRetrieve: ['*']
},
copySettings: false
});
```### Setting properties
| Paramater | Type | Description |
| :-------------------------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sourceApplicationID` | `String` | The Application ID where the current index resides |
| `sourceApiKey` | `String` | The API Key for the app where the current index resides |
| `sourceIndexName` | `String` | The index name of the current index |
| `destinationApplicationID` | `String` | The Application ID of where you would like to add the index |
| `destinationApiKey` | `String` | The API Key for the new index |
| `destinationIndexName` | `String` | The new index name |
| `limit` (Optional) | `Number` | Optional: Limit the amount of records to transfer |
| `requestOptions` (Optional) | `Object` | Optional: Object containing request options for [browseAll](https://www.algolia.com/doc/api-reference/api-methods/browse/?language=javascript#browse-compatible-search-parameters) |
| `copySettings` (Optional) | `Boolean` | Optional: Copy destination settings with the transformation |### Usage
#### Copy
```js
algoliaIndexTransform.copy();
```#### Map
```js
algoliaIndexTransform.map(item => ({
id: item.id
}));
```#### Filter
```js
algoliaIndexTransform.filter(item => item.popular === true);
```#### Reduce
```js
algoliaIndexTransform.reduce((acc, cur) => acc + cur);
```