Hi, Can Typesense sort result by distance?
# community-help
r
Hi, Can Typesense sort result by distance?
k
👋 For geo search?
r
yes
k
Yes it can do that. Let me find the docs.
r
query response need to be sorted by distance so the result will show documents near to the user first
k
Check the sort_by clause in the geo search example.
r
thank you
k
👍
r
Hi, sorry for asking too many question here 🙏. Please tell me if I can put list of strings as field (not going to index it)
k
No worries. Yes, you can have a list of strings. If the field name is not mentioned in the schema, it will be stored (and returned in response) but not indexed.
r
thank you for your fast response.
Hi, I got error while creating a collection.
Error: Request failed with HTTP code 400 | Server said: Wrong format for
fields
. It should be an array of objects containing
name
,
type
,
optional
and
facet
properties.
beside this 4 properties I included "index": false also for some field
k
Can you post the exact schema sent?
r
{
"name": "businessId",
"type": "string",
"index": false
},
{
"name": "businessName",
"type": "string",
"index": false
}
{
"name": "BPS",
"fields": [
{
"name": "id",
"type": "string",
"index": false
},
{
"name": "name",
"type": "string",
},
{
"name": "address",
"type": "string",
"index": false
},
]
}
it will be something like this...
k
I see some trailing commas.
"type": "string",
},
Also you should not include the
id
field in the schema.
r
thank you
👍 1
hi do which type should I use to store timestamp so that I can retrieve only data which not expired
k
int64
r
or thank you, I have my DateTime stores as String (2023-01-01T000000.000)
in firestore
k
You will have to convert to timestamp for indexing because typesense does not have a datetime type that can parse that format.
r
I am using firebase extension. firestore doesn't have timestamp format so I converted the date from timestamp to string (Iso8601String). is there any way. otherwise I should handle it client side.
k
You can store as an integer, correct?
r
you mean, need to convert timestamp to int64 in client side and save it on the firestore as int
k
Yes, store timestamp in firestore as an integer, which can then be mapped to Typesense without any type change.
r
oh. thank you.
👍 1
Hi Kishore, can i query Typesense from POSTMAN, where I will put my search only API Key
k
Yes, you can do that.
r
<http://xxxx-1.a1.typesense.net:443/collections/students/documents/search?q=search-term&query_by=name&auth=MySearchKey|xxxx-1.a1.typesense.net:443/collections/students/documents/search?q=search-term&query_by=name&auth=MySearchKey>
this is how I structured the url. it is not working
k
How are you passing the typesense API key? You have to send it either as a header or as a parameter in the get request.
r
auth=MySearchKey
k
But that's not how Typesense authenticates. Where did you see that example?
r
I use that format in elastic search
and I couldn't find in Typesense docs for direct HTTP
k
You have to send a header:
Copy code
"X-TYPESENSE-API-KEY": "FOO"
r
I will do, thank you
k
I will also update the Authentication docs page to make this clearer.