@searchkit/apollo-resolvers
v3.0.0-canary.24
Published
Elasticsearch GraphQL Resolvers for Apollo Server
Downloads
25
Readme
Searchkit
Searchkit Apollo Resolvers
Searchkit Apollo Resolvers is a library which allows you to build a Search API designed for Search UI experiences on top of Apollo Server. It integrates with Elasticsearch to provide search features like full-text search, faceted filtering and query highlighting.
Documentation
All Searchkit documentation can be found at: https://searchkit.co/docs/
The Searchkit Apollo Resolvers API reference can be found at: https://searchkit.co/docs/reference/apollo-resolvers
Quick Intro
From a configuration
const searchkitConfig = {
host: 'https://localhost:9200',
index: 'movies',
hits: {
fields: [ 'title', 'plot', 'poster' ]
},
query: new MultiMatchQuery({
fields: [ 'plot','title^4']
}),
facets: [
new RefinementSelectFacet({
field: 'type.raw',
identifier: 'type',
label: 'Type'
}),
new RefinementSelectFacet({
field: 'writers.raw',
identifier: 'writers',
label: 'Writers',
multipleSelect: true
}),
new RangeFacet({
field: 'metaScore',
identifier: 'metascore',
label: 'Metascore',
range: {
min: 0,
max: 100,
interval: 5
}
}),
new DateRangeFacet({
field: 'released',
identifier: 'released',
label: 'Released'
})
]
}
Will provide a GraphQL API where you can perform queries like:
Simple Hits
{
results(query: "heat") {
hits {
items {
id
fields {
title
}
}
}
}
}
Facets
{
results(query: "heat") {
facets {
id
label
type
display
entries {
id
label
count
}
}
hits {
items {
id
fields {
title
}
}
}
}
}
Filtering
{
results(filters: [{id: "type", value: "Movie"}, {id: "metascore", min: 30}]) {
facets {
identifier
label
type
display
entries {
id
label
count
}
}
hits {
items {
id
fields {
title
}
}
}
}
}
See Schema Query Guide for more examples.