https://github.com/atlassian-labs/graphqltoelasticsearchtranslator
This package translates graphQL filer query to Elasticsearch query
https://github.com/atlassian-labs/graphqltoelasticsearchtranslator
elasticsearch graphql
Last synced: 4 months ago
JSON representation
This package translates graphQL filer query to Elasticsearch query
- Host: GitHub
- URL: https://github.com/atlassian-labs/graphqltoelasticsearchtranslator
- Owner: atlassian-labs
- License: apache-2.0
- Created: 2021-03-05T18:59:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T18:47:36.000Z (about 4 years ago)
- Last Synced: 2025-02-23T16:13:35.938Z (4 months ago)
- Topics: elasticsearch, graphql
- Language: TypeScript
- Homepage:
- Size: 193 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# GraphQL to ElasticSearch Library
This is an implementation for translating GraphQL Queries to Elasticsearch DSL
# Usage guide
## Install the library:```
npm install --save graphql-elasticsearch
```# Development guide
## Install dependencies
```
npm install
```## Useful commands
```
# Run all checks
npm test```
## How to use the filter
```
import { QueryGenerator } from 'graphql-elasticsearch';let args = {email:'[email protected]'}; // Graphql query args
const testFilterConfig: any = {
filter: {
isNull: ['id'],
isNotNull: ['email'],
arguments: {
id: {
description: 'Unique Identifier',
db_field_name: 'id',
db_type: 'keyword',
type: 'string'
},
email: {
description:
'This endpoint takes a contact (email) and returns all link documents for that contact.',
db_field_name: 'email.raw',
db_type: 'keyword',
type: 'string'
},
and: {
description: 'AND operator',
db_field_name: 'None',
db_type: 'None',
type: 'array'
},
or: {
description: 'OR operator',
db_field_name: 'None',
db_type: 'None',
type: 'array'
},
not: {
description: 'NOT operator',
db_field_name: 'None',
db_type: 'None',
type: 'array'
},
isNotNull: {
description: 'field name is not null',
db_field_name: 'None',
db_type: 'None',
type: 'string'
},
isNull: {
description: 'field name is null',
db_field_name: 'None',
db_type: 'None',
type: 'string'
}
}
}
};let query = bodybuilder();
query = new QueryGenerator().getFilterQuery(query,args,filterConfig);ES query:
"query": {
"bool": {
"must": [{
"term": {
"email.raw": "[email protected]"
}
}]
}
}
```