Eric Jacobsen
04/23/2024, 5:23 PMstring[]
fields
I have a schema that looks something like this:
{
name: 'properties',
enable_nested_fields: true,
fields: [
{
name: 'name',
type: 'string',
},
{
name: 'locationTokens',
type: 'string[]',
facet: true,
},
],
}
and a sample data entry might be…
{
name: 'My Cool Cafe',
locationTokens: ['Williamsburg', 'Brooklyn', 'New York City', 'New York, USA', 'Gentrification Fallout Zone']
}
I can query 'Williamsburg' and it works great. But I'm also doing typeahead searches where I want these tokens to show up, e.g. if I type in "New York" I'd like to see New York City
and New York, USA
returned. Right now I'm just getting all documents, and reducing all the locationTokens
hits for unique values, very inefficient.
Is there a better way to say (say in SQL parlance) SELECT distinct(locationToken) from properties.locationTokens
? Or do I just need a second Typesense collection to track them?Jason Bosco
04/23/2024, 6:22 PMEric Jacobsen
04/23/2024, 6:23 PM