Troubleshooting Typesense Connection Issue and Data Retrieval
TLDR Felix encountered issues connecting to a server-created typesense and retrieving data collections. Kishore Nallan and Jason provided guidance, highlighting errors in the original code and suggesting changes to the URL and curl command.
Jan 04, 2022 (22 months ago)
Felix
06:38 AMI need your help related to typesense connection.
I have created typesense on the server and tried to create collection from my local system with config of the server, but getting error. I have shared screenshot as well. So, anyone please help me out on this.
Thanks
Kishore Nallan
06:39 AMKishore Nallan
06:40 AMFelix
06:41 AMKishore Nallan
06:42 AMKishore Nallan
06:42 AMFelix
06:42 AMKishore Nallan
06:42 AMlocalhost:8108
Felix
06:43 AMFelix
06:43 AMFelix
06:44 AMFelix
06:44 AMFelix
06:44 AMKishore Nallan
06:45 AM$this->client
just before the create()
call?Kishore Nallan
06:45 AMFelix
06:48 AMKishore Nallan
06:49 AM<http://search2.thebestrealestatesearch.com:8108/health>
is showing healthy.Kishore Nallan
06:51 AM/etc/hosts
? Whether you have some mapping that resolves that domain to localhost on your local machine?Felix
06:52 AMFelix
06:52 AMKishore Nallan
06:52 AMFelix
06:53 AMKishore Nallan
06:53 AMKishore Nallan
06:54 AMFelix
06:54 AMKishore Nallan
06:55 AMFelix
06:55 AMhttps://github.com/typesense/typesense-php/blob/master/examples/collection_operations.php
Felix
06:55 AMKishore Nallan
06:55 AMFelix
07:33 AMKishore Nallan
07:34 AMcurl
from the CLI?Kishore Nallan
07:34 AMshell
tab in the examples in the docs. Try doing a shell curl
.Kishore Nallan
07:35 AMFelix
08:21 AMFelix
08:23 AMFelix
08:23 AMFelix
08:23 AM$booksSchema = array();
$booksSchema['name'] = 'property_residentials';
$booksSchema['fields'] = array();
$t = array();
$t['name'] = 'property_id';
$t['type'] = 'int32';
array_push($booksSchema['fields'], $t);
$t = array();
$t['name'] = 'AcresTotal';
$t['type'] = 'float';
array_push($booksSchema['fields'], $t);
$booksSchema['default_sorting_field'] = 'property_id';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($booksSchema));
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-Typesense-Api-Key: APIKEY';
// $headers[] = 'X-Typesense-Api-Key: nXSIQvLOVAc9mg1wYKL9SSdOHzYulqTCcnauUEIdulqt5nSt';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
dd($result);
Kishore Nallan
08:24 AMcurl
command. Check the shell
tab in the examples, like here: https://typesense.org/docs/0.22.1/api/collections.html#with-pre-defined-schemaKishore Nallan
08:25 AM/collections
and not /collection
Kishore Nallan
08:25 AMKishore Nallan
08:26 AMcurl_setopt($ch, CURLOPT_URL, '');
to:
curl_setopt($ch, CURLOPT_URL, '');
Kishore Nallan
08:26 AM// $headers[]
should not be commented out.Felix
08:28 AMFelix
08:46 AMResolved the issue with curl
1. create collection done
2. insert data in collection done
3. getting issue with get collection data (Please help me out on this)
Kishore Nallan
08:47 AMFelix
08:48 AMFelix
08:48 AM$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-Typesense-Api-Key: APIKEY';
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
dd($result);
Kishore Nallan
08:48 AMFelix
08:48 AMKishore Nallan
08:54 AMFelix
08:55 AMKishore Nallan
08:56 AMKishore Nallan
08:56 AMFelix
09:02 AMFelix
10:02 AMThanks Kishore :thumbsup:
Kishore Nallan
10:03 AMFelix
10:06 AMlet me share you my code.
Felix
10:11 AMKishore Nallan
10:12 AMFelix
02:19 PMI need your help related to typsense port and ssl stuff.
Felix
02:19 PMJason
05:31 PMJason
05:32 PMTypesense
Indexed 2779 threads (79% resolved)
Similar Threads
Resolving Typesense Server Connection with Correct API Keys and Paths
Rubai had trouble creating a working API key for Typesense and understanding number_hits versus num_documents. Jason provided clarification and correct code for generating a search-only API Key and using correct server configurations.
Troubleshooting Issues with DocSearch Hits and Scraper Configuration
Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.
Troubleshooting Typesense Docsearch Scraper Setup Issue
Vinicius experienced issues setting up typesense-docsearch-scraper locally. Jason identified a misconfiguration with the Typesense server after checking the .env file, and recommended using ngrok or port forwarding for development purposes. Vinicius successfully resolved the issue with port forwarding.
Issues with Importing Typesense Collection to Different Server
Kevin had problems migrating a Typesense collection between Docusaurus sites on different machines. Jason advised them on JSONL format, handling server hosting, and creating a collection schema before importing documents, leading to successful import.
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.