我正在尝试从React应用程序中搜索Typesense云节点,但我得到的只是控制台中的404 - Not Found错误。我在用
"typesense-instantsearch-adapter": "^2.4.1-1",这是我的反应成分:
import React from "react";
import ReactDOM from "react-dom";
import { SearchBox, InstantSearch, Hits } from "react-instantsearch-dom";
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "myapikey",
nodes: [
{
host: "mytypesensecloudnode-1.a1.typesense.net",
port: 443,
protocol: "https",
},
],
cacheSearchResultsForSeconds: 2 * 60,
},
additionalSearchParameters: {
query_by: "company_name,num_employees,country",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;
export const SearchContainer = () => (
<InstantSearch indexName="products" searchClient={searchClient}>
<SearchBox />
<Hits />
</InstantSearch>
);输入框显示正确,但当应用程序启动时,我只得到这样一条控制台消息:

然后,当尝试搜索时,这个响应有效负载:

我不知道什么东西没被找到。我已经确保Typesense云节点URL和API键都是正确的。这条信息到底指的是什么,我在这里做错了什么?
编辑我的模式:
{
"created_at": 1649772949,
"default_sorting_field": "num_employees",
"fields": [
{
"facet": false,
"index": true,
"name": "company_name",
"optional": false,
"type": "string"
},
{
"facet": true,
"index": true,
"name": "num_employees",
"optional": false,
"type": "int32"
},
{
"facet": true,
"index": true,
"name": "country",
"optional": false,
"type": "string"
}
],
"name": "companies",
"num_documents": 4,
"symbols_to_index": [],
"token_separators": []
}发布于 2022-04-20 02:24:47
indexName道具需要匹配Typesense中的集合名。所以你想改变:
<InstantSearch indexName="products" searchClient={searchClient}>至
<InstantSearch indexName="companies" searchClient={searchClient}>https://stackoverflow.com/questions/71906296
复制相似问题