Debugging Search Issue with Typesense Server Caching
TLDR Jameshwart reported experiencing caching issues with typesense server, despite the server's default setting of not caching. Through troubleshooting steps with Kishore Nallan, they were able to confirm an issue with the Typesense Javascript client and resolved it by adding cacheSearchResultsForSeconds: 0
after apiKey
in the initialisation. Laura also participated in discussion, learning about server and client level caching.
Jul 12, 2023 (3 months ago)
Jameshwart
06:18 AMKishore Nallan
06:19 AMJameshwart
06:21 AM1. Woo updates ts
2. Once update successfull
3. woo then send a revalidation request to our next app
4. next app queries data to ts but the problem is the cache. The response is a cache version.
so I am checking if there is a way to use the search without getting cache response
Jameshwart
06:23 AMKishore Nallan
06:24 AMKishore Nallan
06:24 AMJameshwart
06:24 AMJameshwart
06:25 AMKishore Nallan
06:26 AMJameshwart
06:26 AMJameshwart
06:32 AMKishore Nallan
06:32 AMJameshwart
06:33 AMJameshwart
06:36 AMKishore Nallan
06:36 AMJameshwart
06:36 AMJameshwart
06:36 AMKishore Nallan
06:36 AMJameshwart
06:38 AMJameshwart
06:40 AMKishore Nallan
06:40 AMJameshwart
06:42 AMKishore Nallan
06:42 AMJameshwart
06:43 AMKishore Nallan
06:45 AMJameshwart
06:47 AM1. run next.js app on dev env and visit a product.
2. update the product with small change
3. then i reload the dev page i open in step 1
4. page is not updated
5. wait for a minute
6. reload the product page again. This time it will show the updated data
Kishore Nallan
06:48 AMJameshwart
06:48 AMKishore Nallan
06:48 AMJameshwart
06:51 AMKishore Nallan
06:51 AMJameshwart
06:51 AMKishore Nallan
06:52 AMJameshwart
06:52 AMKishore Nallan
06:52 AMJameshwart
06:53 AMKishore Nallan
06:55 AMJameshwart
06:56 AMKishore Nallan
06:56 AMKishore Nallan
06:57 AMJameshwart
06:57 AMKishore Nallan
06:57 AMJameshwart
06:58 AMconst getProductBySlug = async (sku: string): Promise<ITSProduct | null> => {
let searchParameters = {
q: '*',
query_by: 'slug',
filter_by: `slug:=[${sku}]`,
sort_by: '_text_match:desc',
facet_by: 'slug',
};
const results = await client
.collections(TS_CONFIG.collectionNames.product)
.documents()
.search(searchParameters);
let found = null;
if (typeof results.hits !== 'undefined' && results.hits[0]) {
const tsProductData: ITSProduct = JSON.parse(
JSON.stringify(results.hits[0].document)
);
return tsProductData;
}
return found;
};
Jameshwart
06:59 AMJameshwart
06:59 AMKishore Nallan
07:00 AMclient
is initialized?Jameshwart
07:01 AMimport { Client } from 'typesense';
import TS_CONFIG from './config';
const c = new Client(TS_CONFIG.server);
export default c;
give me a sec i'll get you the ts_config
Jameshwart
07:01 AMconst TS_CONFIG = {
server: {
apiKey: process.env.NEXT_PUBLIC_TS_APIKEY as string, // Be sure to use an API key that only allows search operations
nodes: [
{
host: process.env.NEXT_PUBLIC_TS_HOST as string,
path: '', // Optional. Example: If you have your typesense mounted in localhost:8108/typesense, path should be equal to '/typesense'
port: 443,
protocol: 'https',
},
],
},
collectionNames: {
product: `product-${process.env.NEXT_PUBLIC_TS_STORE_ID}`,
taxonomy: `taxonomy-${process.env.NEXT_PUBLIC_TS_STORE_ID}`,
page: `page-${process.env.NEXT_PUBLIC_TS_STORE_ID}`,
},
};
export default TS_CONFIG;
this is the TS_CONFIG
Kishore Nallan
07:02 AMcacheSearchResultsForSeconds: 0
after apiKey
Jameshwart
07:03 AMJameshwart
07:04 AMKishore Nallan
07:05 AMKishore Nallan
07:05 AMJameshwart
07:06 AMKishore Nallan
07:06 AMJameshwart
07:09 AMJul 13, 2023 (2 months ago)
Laura
12:20 PMLaura
12:21 PMLaura
12:22 PMLaura
12:22 PMJameshwart
12:22 PMKishore Nallan
12:23 PMKishore Nallan
12:24 PMLaura
12:30 PMKishore Nallan
12:32 PMLaura
12:33 PMTypesense
Indexed 2786 threads (79% resolved)
Similar Threads
Troubleshooting TypeScript Error with Typesense
GM experienced an error with Typesense in TypeScript, requiring help to correct the issues. Jason helped propose solutions and adjustments to the code. Ultimately, they were able to resolve the errors and successfully implement a search function.
Enhancing Typesense-JS For Improved Cache Management
Jordan requested a way to clear the cache in 'typesense-js' when a new document is added. Jason recommended a work-around and supported Jordan's idea to add a 'clearCache' method. Jordan then submitted a PR for this implementation.
Issues with Typesense Frontend Search Integration
Akash experienced issues integrating Typesense into their frontend search, particularly with their search box. Jason guided them to troubleshoot, eventually identifying the issue to be with react-instantsearch-dom and suggesting a downgrade to react 17, which resolved the issue.
Resolving Typesense Analytics "top_queries" Collection Issue
Zain faced issues with typesense analytics and an empty "top_queries" collection. Jason and Kishore Nallan assisted in troubleshooting, identified a bug, and suggested a fix in `0.25.0.rc66`. The fix worked for Zain.
Troubleshooting Typesense Setup and Understanding Facets and Keywords
Demitri encountered errors when exploring Typesense for the first time. Jason guided them through troubleshooting and discussed facets, keyword settings, and widget configurations. Helin shared a Python demo app and its source code to help Demitri with their project.