Skip to content

Instantly share code, notes, and snippets.

@gkielwasser
Created November 3, 2021 14:09
Show Gist options
  • Save gkielwasser/d2758d2186c7c2ea16a1fdbac273843f to your computer and use it in GitHub Desktop.
Save gkielwasser/d2758d2186c7c2ea16a1fdbac273843f to your computer and use it in GitHub Desktop.
Typesense - duplicated field in schema
client.aliases().upsert('warehouses', {
'collection_name': 'dev-warehouses-v1.0.1-d'
})
client.collections().create({
version: 'v1.0.1-d',
alias: 'warehouses',
name: 'dev-warehouses-v1.0.1-d',
fields: [
{ name: 'id', type: 'string', facet: false },
{ name: 'name', type: 'string', facet: false },
{ name: 'location.geometry', type: 'geopoint', facet: false },
{
name: 'location.address.canton.id',
type: 'string',
facet: false
},
{
name: 'location.address.canton.translations.fr-CH.translation',
type: 'string',
facet: true
},
{
name: 'location.address.canton.translations.de-DE.translation',
type: 'string',
facet: true
},
{
name: 'location.address.canton.translations.it-IT.translation',
type: 'string',
facet: true
},
{
name: 'location.address.canton.translations.en-US.translation',
type: 'string',
facet: true
},
{
name: 'craftsman.super_craftsman',
type: 'bool',
optional: true,
facet: true
},
{
name: 'craftsman.production_labels.*.*',
type: 'string[]',
optional: true,
facet: true
},
{
name: 'date_updated',
type: 'int64',
facet: false,
_type: 'date'
}
]
})
client.collections('warehouses').documents().upsert({
id: 'cf84f59d-c6a7-4160-ba57-f5aa2f11e03a',
name: 'Hof Baumgarten',
'location.geometry': [ 47.4823896, 7.6416678 ],
'location.address.canton.id': '6f4bf1c2-c411-44fc-8800-f5fa990b9f8d',
'location.address.canton.translations.fr-CH.translation': 'Soleure',
'location.address.canton.translations.de-DE.translation': 'Solothurn',
'location.address.canton.translations.it-IT.translation': 'Soletta',
'location.address.canton.translations.en-US.translation': 'Solothurn',
'craftsman.super_craftsman': false,
'craftsman.production_labels.*.*': [ 'Natura-Veal' ],
date_updated: 1635948200
})
@gkielwasser
Copy link
Author

The correct sequence is:

  • create the collection
  • create the alias
  • index the document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment