Skip to content

SpotlightData/searchkit-express

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Searchkit Express

A thin library to create an express to elasticsearch proxy to support the searchkit ui framework

npm install searchkit-express --save
var SearchkitExpress = require("searchkit-express")

Add _search endpoint to root url

if you just want to create a proxy to the root express url then use the SearchkitExpress function directly like this

var app = express()
app.use(bodyParser.json())
//...

SearchkitExpress({
  // For HTTP basic auth use format: "http://username:password@localhost:9200" in host parameter
  host:process.env.ELASTIC_URL || "http://localhost:9200", 
  index:'movies',
  queryProcessor:function(query, req, res){
    //do neccessery permissions, prefilters to query object
    //then return it
    return query
  }
 }, app)

then in your Clientside UI code

const searchkit = new SearchkitManager("/")

Alternative express router

If you wish to get hold of an express.Router instance so you can configure the suburl and add specific express middleware; use as follows

var app = express()
app.use(bodyParser.json())

//...

var searchkitRouter = SearchkitExpress.createRouter({
  host:process.env.ELASTIC_URL || "http://localhost:9200",  
  index:'movies',
  maxSockets:500, // defaults to 1000
  queryProcessor:function(query, req, res){
    console.log(query)    
    return query
  }
 })
app.use("/movie-search", searchkitRouter)

then in your Clientside UI code

const searchkit = new SearchkitManager("/movies-search")

Debugging

To enable debugging, enable debugging by setting environment variable when starting your server.

DEBUG=SearchkitExpress node server.js

About

Elasticsearch express middleware

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%