Typesense 始终 returns“404 - 未找到”
Typesense always returns "404 - Not Found"
我正在尝试从 React 应用程序搜索 Typesense Cloud 节点,但我得到的只是控制台中的 404 - Not Found
错误。我正在使用
"typesense-instantsearch-adapter": "^2.4.1-1",
这是我的 React 组件:
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 Cloud 节点 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": []
}
indexName
属性需要匹配 Typesense 中的集合名称。所以你想改变:
<InstantSearch indexName="products" searchClient={searchClient}>
至
<InstantSearch indexName="companies" searchClient={searchClient}>
我正在尝试从 React 应用程序搜索 Typesense Cloud 节点,但我得到的只是控制台中的 404 - Not Found
错误。我正在使用
"typesense-instantsearch-adapter": "^2.4.1-1",
这是我的 React 组件:
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 Cloud 节点 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": []
}
indexName
属性需要匹配 Typesense 中的集合名称。所以你想改变:
<InstantSearch indexName="products" searchClient={searchClient}>
至
<InstantSearch indexName="companies" searchClient={searchClient}>