Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the client to be initialized with a path prefix #76

Closed
pulkitsinghal opened this issue Mar 29, 2014 · 4 comments
Closed

Allow the client to be initialized with a path prefix #76

pulkitsinghal opened this issue Mar 29, 2014 · 4 comments

Comments

@pulkitsinghal
Copy link

It helps to front-end elasticsearch with services like APIGEE that can act as a proxy.

Usually this means connecting to something like my.apigee.com/v1/proxy/_search instead of my.es.com/_search ... notice the difference being an additional prefix in the path /v1/proxy/

Can elasticsearch client initialization be tweaked to accomodate this by accepting a url prefix that it would add to all standard requests?

@pulkitsinghal
Copy link
Author

I do understand that instead of trying something like:

host: {
    protocol: 'http',
    host: 'my.apigee.com',
    prefix: 'v1/proxy' // bogus, made up by me
}

I can use http://my.apigee.com/v1/proxy to get the desired effect today.

I am just curious if it can be done in a cleaner fashion like upstairs as well?

@spalger
Copy link
Contributor

spalger commented Mar 29, 2014

Sure thing. Instead of using the prefix: key, use the path: key to accomplish this.

@spalger spalger closed this as completed Mar 29, 2014
@pulkitsinghal
Copy link
Author

thanks @spenceralger is there somethign for placing headers as well? where can the docs be updated to reflect path and header configurations?

@spalger
Copy link
Contributor

spalger commented Mar 31, 2014

Yep, the host objects closely mimic the object that node's http.request accepts as it's argument. I'm surprised that I didn't write docs for those objects; it is on my TODO list now.

In the mean time, here is a detailed list of all the keys you can use to describe a host and their defaults:

var client = new elasticsearch.Client({
  hosts: [
    {
      protocol: 'http',
      host: 'localhost', // can also be hostname: 
      path: '/', // can also be pathname:
      port: 9200,
      auth: null, // Basic authentication i.e. 'user:password' to compute an Authorization header.
      query: null, // query string, or an object which will be serialized to a query string
      headers: null // object, this is only supported in node and es.jquery.js, expect full support soon
    }
  ]
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants