Zain Haider
08/10/2023, 10:03 AMversion: '3.4'
services:
typesense:
image: typesense/typesense:0.25.0.rc62
restart: on-failure
ports:
- "8108:8108"
volumes:
- ./typesense-data:/data
command: '--data-dir /data --api-key=xyz --enable-cors --enable-search-analytics=true --analytics-flush-interval=60'
TIAKishore Nallan
08/10/2023, 11:08 AMZain Haider
08/10/2023, 1:06 PMZain Haider
08/10/2023, 1:07 PMcurl -k "<http://localhost:8108/collections>" -X POST -H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
"name": "top_queries",
"fields": [
{"name": "q", "type": "string" },
{"name": "count", "type": "int32" }
]
}'
used this req to create the schemaZain Haider
08/10/2023, 1:08 PMZain Haider
08/10/2023, 1:59 PMthis.typeSenseClient.collections( collectionName ).retrieve();
this is how i am retrieving the collection . I am using typesense client for node/nest jsZain Haider
08/10/2023, 2:22 PMKishore Nallan
08/10/2023, 2:29 PMJason Bosco
08/10/2023, 2:30 PMGET /analytics/rules
and post the output?Zain Haider
08/10/2023, 2:33 PMZain Haider
08/10/2023, 2:34 PMKishore Nallan
08/10/2023, 2:37 PMJason Bosco
08/10/2023, 2:37 PMZain Haider
08/10/2023, 2:42 PMZain Haider
08/10/2023, 2:45 PMconst productSchema: CollectionCreateSchema = {
name: this.collectionName,
fields: [
{ name: "id", type: "string" },
{ name: "name", type: "string" },
{ name: "description", type: "string" },
{ name: "category", type: "string[]" },
{ name: "brand", type: "string" },
{ name: "company", type: "string" },
{ name: "status", type: "bool" },
{ name: "isHidden", type: "bool" }
]
};
await this.searchService.createCollection( productSchema );
Search Query:-
const searchParams: SearchParams = {
enable_overrides: true,
filter_by: "status:=true && isHidden:=false",
q: query,
query_by: "name,description,category,brand,company"
};
const product = await this.searchService.searchFromCollection( this.collectionName, searchParams );
Jason Bosco
08/10/2023, 3:15 PMZain Haider
08/10/2023, 3:17 PMZain Haider
08/10/2023, 4:45 PMJason Bosco
08/10/2023, 4:49 PMStep 6 Now search on Product collection (Repeat Step 3)Repeated the step 3 time to check the count of query “garam” You’re waiting at least 60s after this step right? Because that’s what this parameter does:
analytics-flush-interval=60
Jason Bosco
08/10/2023, 4:50 PMZain Haider
08/10/2023, 6:36 PMZain Haider
08/10/2023, 6:36 PMcurl -H "X-TYPESENSE-API-KEY: xyz" \
"<http://localhost:8108/collections/top_queries/documents/search>\
?q=*&query_by=q"
this req gives this result
{"facet_counts":[],"found":0,"hits":[],"out_of":0,"page":1,"request_params":{"collection_name":"top_queries","per_page":10,"q":"*"},"search_cutoff":false,"search_time_ms":3}
Zain Haider
08/10/2023, 6:36 PMJason Bosco
08/10/2023, 7:15 PMZain Haider
08/10/2023, 7:34 PMKishore Nallan
08/11/2023, 5:19 AM0.25.0.rc66
-- can you please try that out?Zain Haider
08/11/2023, 6:22 AMZain Haider
08/11/2023, 8:41 AMZain Haider
08/11/2023, 8:41 AMNeil
09/26/2023, 3:16 PM"fields": [
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "q",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "count",
"optional": false,
"sort": true,
"type": "int32"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "timestamp",
"optional": true,
"sort": true,
"type": "int64"
}
]
One of my main collections (I have 2) has a scheme like this - not sure if it matters:
"fields": [
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": ".*",
"optional": true,
"sort": false,
"type": "auto"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "category",
"optional": true,
"sort": false,
"type": "object"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "description",
"optional": true,
"sort": false,
"type": "string"
}
Appreciate the help!Jason Bosco
09/26/2023, 3:18 PM0.25.2.rc1
and try again?Neil
09/26/2023, 3:19 PMJason Bosco
09/26/2023, 3:20 PMNeil
09/26/2023, 3:27 PMNeil
09/26/2023, 7:41 PM