-
Notifications
You must be signed in to change notification settings - Fork 728
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
Issues using { Client } #814
Comments
Hello! |
yes, i'im
Yes @delvedor, i'm using React client-side |
This client is not intended to be used in a browser environment.
Yes. |
Ah, ok thanks for this information. |
In this case, I suggest you take a look at elastic/search-ui If you want to build your own system, I recommend you to put a simple Node.js server (which uses this client) between your React app and Elasticsearch. |
Wow, thank you so much! |
Because i haven't an Elastic App Search |
Solved really fast working server-side! |
Hello! |
Hi thank you so much and sorry i forget to close it!
Il giorno ven 26 apr 2019 alle ore 10:48 Tomas Della Vedova <
notifications@github.com> ha scritto:
… Closed #814 <#814>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#814 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJEBVOLWWO6ESQC3DIOGOZ3PSK6U7ANCNFSM4HFOKYHA>
.
|
It seems like this issue also occurs in Cloudflare's workers, any way to work around it? |
@arunesh90 I don't suppose you found the issue with this? |
What was the solution for this issue ? |
@tdossett I couldn't get it to work, so I just used the es rest api with fetch/exios etc. |
I see i was thinking about doing the same thing since elasticsearch.js using { Client } does not work yet. THX do you have sample fetch, axios example ? |
Pulled from a quick workers & graphql demo app: const endpoint = `${endpoint}/_search`
const credentials = new Buffer.from(`${username}:${password}`).toString('base64')
module.exports = {
SearchResult: {
__resolveType(obj, context, info){
if (obj.first_name) return 'Contact'
if (obj.name) return 'Company'
return null
},
},
Query: {
search: async (parent, { query }, ctx, info) => {
try {
const queryBody = {
multi_match: {
query,
fields: ['*_name^3', 'company'],
fuzziness: 'AUTO'
}
}
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Basic ${credentials}`
},
body: JSON.stringify({ query: queryBody })
})
const data = await response.json()
const results = data.hits.hits.map(hit => hit._source)
return results
} catch (error) {
throw new Error(error.message)
}
}
}
} |
Hi Travis,
I ended up following your lead and did the following:
![axios_call](https://user-images.githubusercontent.com/15810761/67967764-6d275700-fbc3-11e9-8838-d4e74311c8c8.png)
1. I used ‘axios’ to perform the https get request (normally I had ‘url’ and ‘auth’, but wanted to be more specific).
![elsaticsearch_yml_settings](https://user-images.githubusercontent.com/15810761/67967864-97791480-fbc3-11e9-8107-8cb35b293b04.png)
2. In my Elastic subscription I enable ‘cors’.
AND NOW IT WORKS in Heroku ….
Thank You Again 😊 …
|
Hi, i'm trying to use the es client with Es6 + React, for connect my app into the elastic cloud using the code from the examples:
import { Client } from '@elastic/elasticsearch'; const client = new Client({ cloud: { id: 'Cloud-Name:Cloud-Id', username: 'elastic', password: 'my-password' } });
But when i launch the program it takes me this error
what could be the issue?
The text was updated successfully, but these errors were encountered: