#community-help

Updating Documents by Query and Sorting by Float Fields

TLDR Saurabh asked how to update documents by query and whether float fields can be used for sorting. Kishore Nallan provided information on updating by query and advised using int64 type instead of float for unix timestamps.

Powered by Struct AI

1

May 25, 2023 (6 months ago)
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:15 AM
Hi Team,
Can't We Update Documents By Query ?
Jason, Kishore Nallan
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:24 AM
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:29 AM
how can we use this for now ?
09:29
Saurabh
09:29 AM
Kishore Nallan
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:33 AM
Are you on typesense cloud? or self hosting?
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:35 AM
self hosting
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:39 AM
Docker?
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:41 AM
no
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:53 AM
Then how do you deploy? Provide details and I can share appropriate build.
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:53 AM
i just installed it using pip...
09:54
Saurabh
09:54 AM
and further do the crud operations
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:56 AM
I'm talking about the typesense server, not client
09:57
Kishore Nallan
09:57 AM
Do you download deb/rpm/tar gz?
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
09:57 AM
yess
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:24 AM
Which of those do you download?
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
10:25 AM
tar gz
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:40 AM
You can use this build:

Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
10:40 AM
1. One More Qstn, Can we sort_by float fields ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:41 AM
Yes
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
10:53 AM
i think sort_by float field is not working
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:56 AM
Please post a reproduceable end to end example so that we can troubleshoot.
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
11:05 AM
{
"document": {
"name": "Marketing Communications Management - MSc",
"published_date": "2021-12-19 17:10:02.652000",
"published_date_unix": 16399140026520.0,
"sort_order": 1246
},
"highlight": {},
"highlights": []
},
{
"document": {
"name": "Marketing and Brand Management - MSc",
"published_date": "2021-12-19 17:10:02.645000",
"published_date_unix": 16399140026450.0,
"sort_order": 1246
},
"highlight": {},
"highlights": []
},
{
"document": {
"name": "International Business and Marketing Management - MSc",
"published_date": "2021-12-19 17:10:02.567000",
"published_date_unix": 16399140025670.0,
"sort_order": 1246
},
"highlight": {},
"highlights": []
}
}
11:06
Saurabh
11:06 AM
have used sort_by: sort_order:desc, published_date_unix:asc
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:11 AM
What's the float here?
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
11:11 AM
published_date_unix
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:23 AM
Float cannot hold that value properly. Use int64 type.
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
11:23 AM
but i have some values which are in decimls
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:24 AM
unix timestamps are never in float. Use milliseconds or microseconds if you want to represent fractional values of a second.
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
12:36 PM
can you pls share the link for deb ?
01:03
Saurabh
01:03 PM
can you pls share documentation of 0.26.0 ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:52 PM
DEB is here:


We don't have change log yet for 0.26.0.
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
01:55 PM
what would be update_by_query params for python ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:56 PM
You just need to send a param that has filter condition:

{
   "filter_by": "<condition>"
}
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
01:58 PM
client.collections[collection_name].documents[document_id].update(document)

Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:58 PM
document = {
  'company_name': 'Stark Industries',
  'num_employees': 5500
}

client.collections['companies'].documents['124'].update(document, {"filter_by": "<condition>"})
Saurabh
Photo of md5-57be9cd26696982f7dd2392eff28df99
Saurabh
01:58 PM
works thanks

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Issue with Embedding Error in Version 0.25.0.rc63

Bill reported a bug in version 0.25.0.rc63 regarding a problem with updating or emplacing a document and receiving an embedding error. This was resolved in version 0.25.0.rc65, but further discussion ensued regarding the function of 'index' in the update feature.

5

63
4mo

Editing and Updating Schema in Typesense Cloud

Loic sought help editing their Typesense Cloud Schema and adding search parameters. Jason guided them on how to drop a field and add another parameter for searching.

1

12
11mo

Typesense Bug Fix with `canceled_at` Field and Upgrade Concerns

Mateo reported an issue regarding the treatment of an optional field by Typesense which was confirmed a bug by Jason. After trying an upgrade, an error arose. Jason explained the bug was due to a recent change and proceeded to downgrade their version. Future upgrade protocols were discussed.

3

74
10mo

Sorting Results in Typesense and Handling Errors

Ramees asks about sorting results by distance in Typesense, entering a list of strings as a field, and resolving an error with `fields` format. Kishore Nallan assists with these issues and advises on storing timestamps and proper authentication.

2

46
30mo

Handling Kinesis Stream Event Batching with Typesense

Dui had questions about how to handle Kinesis stream events with Typesense. Kishore Nallan suggested using upsert mode for creation/update and differentiating with logical deletion. After various discussions including identifying and resolving a bug, they finalized to introduce an `emplace` action in Typesense v0.23.

8

91
24mo