This package contains a custom render and a set of functions that can be used with @kaliber/build to build mappings. It also holds a set of util functions to query elasticsearch into a more readable format.
yarn add @kaliber/elasticsearch
We like to write clean code. So whe made a set of util functions that help us create more readable mappings and write simple queries to send to the elasticsearch api.
The renderer is used for an internal plugin. So this is probably not that interesting for everybody. But the rest of the project can be used without it.
Note: This library is precompiled using kaliberjs/pack (https://github.com/kaliberjs/pack)
You can find more examples in the /examples
folder.
*.mapping.js
import { text, keyword, object } from '@kaliber/elasticsearch/mapping'
export default {
mappings: {
dynamic: 'strict',
properties: {
id: keyword(),
title: text(),
taxonomy: object({
title: text(),
slug: keyword(),
}),
}
}
}
example.js
import { filter, matchAll, term, search } from '@kaliber/elasticsearch/query'
const searchQuery = 'Waldo'
const taxonomy = 'books'
const query = and(
searchQuery
? search(['title'], searchQuery),
: matchAll(),
filter(
taxonomy && term('taxonomy.slug', taxonomy)
)
)
To configure @kaliber/build to use the custom renderer in this package, you have to update the config/default.js file:
kaliber: {
templateRenderers: {
mapping: '@kaliber/elasticsearch/mapping-to-php-renderer'
}
}
This library is intended for internal use, we provide no support, use at your own risk.