Demitri Muna
03/04/2022, 1:25 AM[Error] Error: 404 - Could not find a facet field named `*` in the schema. — TypesenseInstantsearchAdapter.js:81
_callee$ (app.a6a4d504.js:7599)
tryCatch (app.a6a4d504.js:192)
invoke (app.a6a4d504.js:423)
asyncGeneratorStep (app.a6a4d504.js:890)
_next (app.a6a4d504.js:912)
promiseReactionJob
[Error] Unhandled Promise Rejection: Error: 404 - Could not find a facet field named `*` in the schema.
(anonymous function) (instantsearch.js@4.39.1:2:32449)
(anonymous function) (instantsearch.js@4.39.1:2:105993)
(anonymous function) (instantsearch.js@4.39.1:2:32639)
(anonymous function) (instantsearch.js@4.39.1:2:49241)
(anonymous function)
promiseReactionJob
Is this something I am missing in app.js
?Jason Bosco
03/04/2022, 1:39 AMdynamicWidgets
in app.js? If so, could you remove it and try again?Demitri Muna
03/04/2022, 2:01 AMCould not find a facet named 'abstract' in the schema
. One of my fields in my schema is called “abstract”.Jason Bosco
03/04/2022, 2:02 AMJason Bosco
03/04/2022, 2:02 AMDemitri Muna
03/04/2022, 2:04 AM{
"name": "ascl_entries",
"fields": [
{
"name": "ascl_id",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "title",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "credit",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "abstract",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "topic_id",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "bibcode",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "views",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "preferred_citation",
"type": "string",
"facet": false,
"optional": false,
"index": true
},
{
"name": "site_list",
"type": "string[]",
"facet": false,
"optional": false,
"index": true
},
{
"name": "used_in",
"type": "string[]",
"facet": false,
"optional": false,
"index": true
},
{
"name": "described_in",
"type": "string[]",
"facet": false,
"optional": false,
"index": true
}
],
"default_sorting_field": ""
}
Jason Bosco
03/04/2022, 2:04 AM"facet": true
for the abstract field if you want to use it with instant searchDemitri Muna
03/04/2022, 2:04 AMschema = {
"name" : "ascl_entries",
"fields" : [
{ "name":"ascl_id", "type":"string" },
{ "name":"title", "type":"string"},
{ "name":"credit", "type":"string"},
{ "name":"abstract", "type":"string"},
{ "name":"topic_id", "type":"string"},
{ "name":"bibcode", "type":"string"},
{ "name":"views", "type":"string"},
{ "name":"preferred_citation", "type":"string"},
{ "name":"site_list", "type":"string[]"},
{ "name":"used_in", "type":"string[]"},
{ "name":"described_in", "type":"string[]"}
#{ "name":"keywords", "type":"string[]"},
]#,
# "default_sorting_field": "title" # optional
}
Demitri Muna
03/04/2022, 2:05 AMJason Bosco
03/04/2022, 2:05 AMJason Bosco
03/04/2022, 2:06 AMDemitri Muna
03/04/2022, 2:09 AM"facet":True
to the schema worked. I don’t have the text of the full papers, just the abstracts. I’m not sure what you mean though; the intent was to be able to filter on arbitrary words, e.g. “hydrogen”.Jason Bosco
03/04/2022, 2:10 AMDemitri Muna
03/04/2022, 2:10 AMJason Bosco
03/04/2022, 2:11 AMJason Bosco
03/04/2022, 2:12 AMJason Bosco
03/04/2022, 2:13 AMDemitri Muna
03/04/2022, 2:14 AMkeywords
field in my schema, the data set I am using as a sample doesn’t have any of those populated. I’m not familiar with the refinementList? This is literally my first time using Typesense; just trying to get a minimum working example to see how I might integrate it into a web app. This is the whole of the app.js
, pretty short. I minimally modified it from the template.
const { algoliasearch, instantsearch } = window;
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "zPOYYT6TdNOIK9h87bzv5GPtZXIMaxJC", // Be sure to use the search-only-api-key
nodes: [
{
host: "localhost",
port: "8108",
protocol: "http"
}
]
},
// The following parameters are directly passed to Typesense's search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: {
query_by: "title,abstract"
}
});
const searchClient = typesenseInstantsearchAdapter.searchClient;
const search = instantsearch({
searchClient,
indexName: "ascl_entries"
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: '#searchbox',
}),
instantsearch.widgets.hits({
container: '#hits',
templates: {
item: `
<div>
<img src="" align="left" alt="" />
<div class="hit-name">
{{#helpers.highlight}}{ "attribute": "title" }{{/helpers.highlight}}
</div>
<div class="hit-abstract">
{{#helpers.highlight}}{ "attribute": "abstract" }{{/helpers.highlight}}
</div>
<div class="hit-ascl_id">ASCL ID: </div>
</div>
`,
},
}),
instantsearch.widgets.configure({
facets: ['abstract'],
maxValuesPerFacet: 20,
}),
// instantsearch.widgets.dynamicWidgets({
// container: '#dynamic-widgets',
// fallbackWidget({ container, attribute }) {
// return instantsearch.widgets.refinementList({
// container,
// attribute,
// });
// },
// widgets: [],
// }),
instantsearch.widgets.pagination({
container: '#pagination',
}),
]);
search.start();
Jason Bosco
03/04/2022, 2:15 AMinstantsearch.widgets.configure({
facets: ['abstract'],
maxValuesPerFacet: 20,
}),
Jason Bosco
03/04/2022, 2:15 AMJason Bosco
03/04/2022, 2:16 AMJason Bosco
03/04/2022, 2:17 AMfacet: true
on a field with almost all unique values across records ends up using a lot of memory...Demitri Muna
03/04/2022, 2:18 AMJason Bosco
03/04/2022, 2:18 AMDemitri Muna
03/04/2022, 2:19 AMJason Bosco
03/04/2022, 2:23 AMcolor
, brand
as faceted field, so you can display a filter to users that lets them drill-down products based on color or brand.Demitri Muna
03/04/2022, 2:28 AMDemitri Muna
03/04/2022, 2:30 AMJason Bosco
03/04/2022, 2:30 AMI’d get a unique list of all keywords for the entries that match “planets”.Did you mean unique list of records, or keywords?
Jason Bosco
03/04/2022, 2:32 AMDemitri Muna
03/04/2022, 2:36 AMJason Bosco
03/04/2022, 2:36 AMJason Bosco
03/04/2022, 2:37 AMDemitri Muna
03/04/2022, 2:37 AMJason Bosco
03/04/2022, 2:38 AMDemitri Muna
03/04/2022, 2:38 AMJason Bosco
03/04/2022, 2:39 AMDemitri Muna
03/04/2022, 2:40 AMDemitri Muna
03/04/2022, 2:40 AMJason Bosco
03/04/2022, 2:40 AMJason Bosco
03/04/2022, 2:43 AMIn the interface you linked, I suppose I’m looking for an AND search rather than OR.This is also possible. The brand filter uses this refinementList widget which does an OR by default. You can change it to AND like this: https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/#widget-param-operator
Demitri Muna
03/04/2022, 2:45 AMDemitri Muna
03/04/2022, 2:49 AMJason Bosco
03/04/2022, 2:49 AMDemitri Muna
03/04/2022, 2:51 AMJason Bosco
03/04/2022, 2:52 AMDemitri Muna
03/04/2022, 2:53 AMJason Bosco
03/04/2022, 2:54 AMJason Bosco
03/04/2022, 4:41 AMHelin Cao
03/04/2022, 4:47 AMDemitri Muna
03/15/2022, 3:28 PMHelin Cao
03/30/2022, 7:35 PMDemitri Muna
03/30/2022, 8:09 PMHelin Cao
03/30/2022, 10:23 PMpip install pywebio
), or run it on build.pyweb.io.
Note that the live demo does not work anymore as my Typesense cloud usage has exceeded the free tier limit. I should probably ask for a complete free account for this demo purpose (cc @Jason Bosco 🙂 )Jason Bosco
03/30/2022, 10:50 PMHelin Cao
03/31/2022, 12:06 AM