簡體   English   中英

在 React 中使用 searchKitManager 時出錯

[英]Error while using searchKitManager in React

我正在嘗試在 react-admin 中使用searchKitManager我根據文檔提供了參數等,但是當我運行代碼時它會引發錯誤。 這是代碼的工作原理

  • React Admin 在http://localhost:3000上運行
  • Golang 后端運行在http://localhost:3006
  • ElasticSearch 在http://localhost:9200上運行

當使用 golang 代碼將數據插入 mysql 數據庫時,它也會稍后在我的一個顯示組件中插入 elasticsearch 我調用上面的 searchkitManager 如下

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`,
});

此代碼將拋出404 Not Found or 400 Bad Request錯誤,但如果我將上述鏈接更改為

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/`,
});

我什么也沒得到,有時控制台中沒有錯誤,有時400 Bad Request or 405 Post Not Allowed

最后一件事我提供的關於searchUrlPath的鏈接應該是這樣嗎? 還是我應該通過apiUrl代替/ 我也試過了,但只是為了確保。

任何形式的幫助將不勝感激。

嘗試這樣做:

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

const searchkit = new SearchkitManager(elasticSearchUrl );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM