Error while using searchKitManager in React

180 Views Asked by At

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.

1

There are 1 best solutions below

0
rex On

Try doing this:

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

const searchkit = new SearchkitManager(elasticSearchUrl );