Handling Field Variations in Typesense for Different Clients
TLDR Yoshi asked for a solution to handle varying contact_date fields for different clients in typesense. Jason recommended using nested fields for the short-term and mentioned future support for joining data across collections.
1
May 04, 2023 (7 months ago)
Yoshi
11:46 PMWe have a collection of companies that we have included in typesense, specifically dentists. Each client has a different contact_date for each dentist.
I’m curious if there is any best practice for handling this kind of field that is different for each company, but wanting to filter/sort by it for each user.
One way I could potentially do this is by adding a different schema field per client:
{
"name": "ABC Company",
"location": "San Francisco",
"latest_contact_date_client_1": "2023-05-04T10:30:00Z",
"latest_contact_date_client_2": "2023-05-04T10:30:00Z",
...
}
But that seems terribly inefficient.
Jason
11:51 PMMay 05, 2023 (7 months ago)
Yoshi
12:06 AMJason
12:08 AMdentists_contacted_by_client_1
and add that dentist record into that collection.Then at search time, you can do a request and fetch results from the user-specific collection sorted by contact time, then do another request to the main collection excluding the IDs for in the first result set
Yoshi
12:15 AMI also worry a little a bit about making that search, since we would need to pass in an extremely large filter_by string to exclude all of the ids, which can be hundreds of thousands of Documents.
Yoshi
12:17 AMenable_nested_fields
be a potential solution?Jason
12:18 AMA client can contact hundreds of thousands of dentists?
Yoshi
12:19 AMJason
12:20 AMJason
12:22 AM{latest_contact_dates: {client_1: 123, client_2: 234}
Jason
12:23 AMJason
12:25 AMYoshi
12:26 AMI’m happy to change our data structure in the future, trying to figure out what would be a good solution for the short to mid term (probably up to 1000 organizations or so)
Jason
12:27 AMJason
12:27 AMJason
12:28 AMYoshi
12:28 AMYoshi
12:31 AM1
Typesense
Indexed 3011 threads (79% resolved)
Similar Threads
Discussions on Typesense, Collections, and Dynamic Fields
Tugay shares plans to use Typesense for their SaaS platform and asks about collection sizes and sharding. Jason clarifies Typesense's capabilities and shares a beta feature. They discuss using unique collections per customer and new improvements. Kishore Nallan and Gabe comment on threading and data protection respectively.
Updating Collections Strategy and Faceting New Field
Nithin asked about strategies for updating collections and faceting new fields. Kishore Nallan suggested creating another collection, indexing in the background and using aliases to switch live traffic over, and shared details about the upcoming release.
Performance Characteristics of Filtering Search Results
Oskar queries the performance difference in filtering search results. Jason clarifies how filters work and provides performance improvement suggestions like increasing vCPUs and sharding the collection. Kishore Nallan explains filter IDs and document ID matching. The thread concludes with discussions on performance tradeoffs in filter implementation.
Issues with Schema Creation and Nested Fields
Sean encountered a problem with schema creation involving auto nested fields. Kishore Nallan suggested checking the API response for errors and adding problematic fields to the schema as optional. Sean confirmed the advice.
Issue with Typesense Schema and Ruby Client
Mateo faces issues while creating a schema and using Ruby client for Typesense. Jason suggests using a new field instead of 'id' and provides assistance for Ruby client errors.