https://github.com/dkd/storyblok-solr-indexer
Storyblok Solr Indexer
https://github.com/dkd/storyblok-solr-indexer
indexer nodejs solr storyblok
Last synced: 3 months ago
JSON representation
Storyblok Solr Indexer
- Host: GitHub
- URL: https://github.com/dkd/storyblok-solr-indexer
- Owner: dkd
- License: gpl-3.0
- Created: 2023-11-08T12:41:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T13:03:29.000Z (over 1 year ago)
- Last Synced: 2025-07-12T07:23:14.219Z (3 months ago)
- Topics: indexer, nodejs, solr, storyblok
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 10
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-storyblok - storyblok-solr-indexer - Indexer script to index Storyblok stories in Apache Solr. (Uncategorized / Uncategorized)
- awesome-storyblok - storyblok-solr-indexer - Indexer script to index Storyblok stories in Apache Solr. (Uncategorized / Uncategorized)
README
# Storyblok Solr Indexer
Indexer to index Storyblok stories in Solr.
## Usage
Install package
```
npm install storyblok-solr-indexer
```### Example Usage
indexer.js
```
mport 'dotenv/config';
import StoryblokSolrIndexer from './StoryblokSolrIndexer.mjs';// Destructure required environment variables for better readability and performance.
const {
STORYBLOK_ACCESS_TOKEN,
SOLR_HOST,
SOLR_PORT,
SOLR_PATH,
SOLR_USER,
SOLR_PASS,
SOLR_CORE,
TEST_DATA
} = process.env;if (!STORYBLOK_ACCESS_TOKEN || !SOLR_HOST || !SOLR_PORT || !SOLR_PATH || !SOLR_USER || !SOLR_PASS || !SOLR_CORE || !TEST_DATA) {
throw new Error('One or more environment variables are missing or invalid');
}// Configure storyblock options with access token and query parameters.
const storyblockOptions = {
accessToken: STORYBLOK_ACCESS_TOKEN,
options: {
starts_with: '',
'filter_query[component][in]': 'Page',
per_page: 100,
page: 1,
version: 'published'
}
};// Configure Solr connection options using environment variables.
const solrOptions = {
host: SOLR_HOST,
port: SOLR_PORT,
path: SOLR_PATH,
user: SOLR_USER,
pass: SOLR_PASS,
core: SOLR_CORE,
};// Parse the test data provided via environment variable.
const data = JSON.parse(TEST_DATA);// Create an instance of StoryblokSolrIndexer and pass the configured options.
const indexer = new StoryblokSolrIndexer(storyblockOptions, solrOptions);indexer.indexStoriesBasedOnAction(data)
```The `data` object passed through the indexer can contain a property `action` and `story_id`.
```
{
"action": "published", // 'unpublished', 'moved', 'deleted'
"story_id": 473816430
}
````
If no action is passed the Solr index is cleared and fully new indexed.Run in Terminal
```
node indexer.js
```## NPM Package
https://www.npmjs.com/package/storyblok-solr-indexer
## Cloudflare
You can find a cloudflare worker using the indexer here:
https://github.com/dkd/cloudflare-worker-storyblok-solr-indexer
## Hosted Solr
You can host your Solr core here:
https://hosted-solr.com/de/