Mateo Salazar
02/08/2023, 8:00 PMschema = {
'name': 'appointments_development',
'default_sorting_field': 'arrival_time',
'fields': [
{ 'name': 'id', 'type': 'string' },
{ 'name': 'shipper_id', 'type': 'string', facet: true },
{ 'name': 'facility_id', 'type': 'string', facet: true },
{ 'name': 'confirmation_id', 'type': 'string', facet: true },
{ 'name': 'facility_name', 'type': 'string', facet: true },
{ 'name': 'dock_id', 'type': 'string' },
{ 'name': 'dock_name', 'type': 'string', facet: true },
{ 'name': 'equipment_type_id', 'type': 'string', facet: true },
{ 'name': 'appointment_type_id', 'type': 'string', facet: true },
{ 'name': 'appointment_type_name', 'type': 'string', facet: true },
{ 'name': 'status', 'type': 'string', facet: true },
{ 'name': 'created_by_id', 'type': 'string' },
{ 'name': 'created_by_name', 'type': 'string', facet: true },
{ 'name': 'scheduler_id', 'type': 'string' },
{ 'name': 'scheduler_name', 'type': 'string', facet: true },
{ 'name': 'checkin_id', 'type': 'string' },
{ 'name': 'checkin_status', 'type': 'string', facet: true },
{ 'name': 'commodity_type', 'type': 'string', facet: true },
{ 'name': 'less_than_truckload', 'type': 'bool', facet: true },
{ 'name': 'repeating', 'type': 'bool', facet: true },
{ 'name': 'purchase_order_identifiers', 'type': 'string[]' },
{ 'name': 'answer_identifiers', 'type': 'string[]' },
{ 'name': 'has_attachments', 'type': 'bool' },
{ 'name': 'color', 'type': 'string' },
{ 'name': 'arrival_time', 'type': 'int64', facet: true },
{ 'name': 'time_zone', 'type': 'string' },
{ 'name': 'created_at', 'type': 'int64' }
]
}
But we noticed the ID field is not being created and we do not understand why as we haven't edit this schema in a while and we were able to create collection with it in the pastJason Bosco
02/08/2023, 8:09 PMBut we noticed the ID field is not being createdAre you referring to the ID field not showing when you view the schema after creating it?
Mateo Salazar
02/08/2023, 8:18 PMMateo Salazar
02/08/2023, 8:18 PMJason Bosco
02/08/2023, 8:28 PMid
field in Typesense has always been a special field we also used internally to deduplicate documents, and it had to be a string type. So it was never really configurable using the schema and it led to confusion.
So in the latest version of Typesense 0.24 (and also in 0.23 IIRC), we essentially disregard the id
field and don’t allow searching / sorting on it, since it has additional implications internally.
So if you need to do other operations on that field, you want to create a new string field in the collection, store the attribute there and then sort / facet on it as neededMateo Salazar
02/09/2023, 3:03 PMvslot_id
, I was trying to delete with a filter_by endpoint but I get this error:
`error_message":"undefined method delete' for <Typesense::Documents:0x0000562b305cbb40>
Mateo Salazar
02/09/2023, 3:03 PMMateo Salazar
02/09/2023, 3:03 PMTypesenseClient.fetch.collections[klass.index_name].documents.delete(filter_by: "vslot_id:=#{id}")
Mateo Salazar
02/09/2023, 3:04 PMMateo Salazar
02/09/2023, 3:09 PMTypesenseClient.fetch.collections[klass.index_name].documents[id].delete
Mateo Salazar
02/09/2023, 4:03 PMJason Bosco
02/09/2023, 4:04 PMJason Bosco
02/09/2023, 4:04 PMJason Bosco
02/09/2023, 4:08 PMJason Bosco
02/09/2023, 4:09 PMJason Bosco
02/09/2023, 4:10 PMMateo Salazar
02/09/2023, 4:12 PMclass TypesenseClient
def self.fetch
@client = Typesense::Client.new(
nodes: [{
host: ENV['TYPESENSE_HOST'],
port: 443,
protocol: 'https'
}],
api_key: ENV['TYPESENSE_API_KEY'],
connection_timeout_seconds: 2
)
@client
end
end
TypesenseClient.fetch.collections['appointments'].documents.delete(filter_by: "vslot_id:=#{id}")
Jason Bosco
02/09/2023, 4:29 PMJason Bosco
02/09/2023, 4:29 PMMateo Salazar
02/09/2023, 5:56 PMweb | {
web | "company_name" => "Stark Industries",
web | "country" => "USA",
web | "id" => "124",
web | "num_employees" => 5215
web | }
web |
web | Typesense::Error::RequestMalformed (The `id` of the resource does not match the `id` in the JSON body.):
Jason Bosco
02/09/2023, 6:13 PMJason Bosco
02/09/2023, 6:13 PMMateo Salazar
02/09/2023, 8:01 PMNoMethodError (undefined method `delete' for #<Typesense::Documents:0x000055b307742f60>):
In this line:
https://github.com/typesense/typesense-ruby/blob/c0e7173b202371cd6cd32f0054b79dbfdbbe5681/examples/collections_and_documents.rb#L262Jason Bosco
02/09/2023, 8:13 PMJason Bosco
02/09/2023, 8:14 PMJason Bosco
02/09/2023, 8:32 PMMateo Salazar
02/09/2023, 8:39 PMJason Bosco
02/09/2023, 8:39 PMMateo Salazar
02/09/2023, 8:44 PMMateo Salazar
02/09/2023, 8:44 PMMateo Salazar
02/09/2023, 8:45 PMMateo Salazar
02/09/2023, 8:56 PMJason Bosco
02/09/2023, 9:02 PM