简体   繁体   中英

Error while using searchKitManager in React

I am trying to use the searchKitManager inside react-admin I provided the parameters etc according to the docs but when I run the code it throws errors. Here is how the code works

  • React Admin is running on http://localhost:3000
  • Golang backend is running on http://localhost:3006
  • ElasticSearch is running on http://localhost:9200

When data is inserted in mysql database using golang code it is also inserted in elasticsearch later on in one of my display component I call the above searchkitManager as follows

let apiUrl= 'http://localhost:9200/donate' // what link should I pass, url to elasticsearch or url to my backend
const searchkit = new SearchkitManager('/', {
  searchUrlPath: `${apiUrl}/_search`,
});

This code will throw 404 Not Found or 400 Bad Request error but the API works in postman if I change the above link to

let apiUrl= 'http://localhost:9200/donate' // what link should I pass, url to elasticsearch or url to my backend
const searchkit = new SearchkitManager('/', {
  searchUrlPath: `${apiUrl}/_doc/`,
});

I am not getting anything at all sometimes it no error in console and sometimes 400 Bad Request or 405 Post Not Allowed

One last thing the link I am providing as for searchUrlPath should be like that or not? or should I pass the apiUrl in place of / ? I tried that as well but just to make sure.

Any kind of help will be really appreciated.

Try doing this:

const elasticSearchUrl =  'http://localhost:9200/<your_index>';

const searchkit = new SearchkitManager(elasticSearchUrl );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM