typesense / typesense/typesense-js
Typing for geo_distance_meters is too strict
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 569
- Forks
- 99
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 2
Description
Issue Statement
The typing at https://github.com/typesense/typesense-js/blob/master/lib/Typesense/Documents.d.ts#L71 is too strict on location. The actual field name depends on the actual collection definition.
Expected Behavior
Either the typing is more lenient allowing [k:string|: number or some generic parameterization is provided to dynamically define the actual geo_distance_meters property name.
Reproduction Scenario
We have a collection with defined with:
name: coordinates
type: geopoint
facet: false
index: true
infix: false
optional: true
sort: true
stem: false
store: true
As a result, our filtering and sorting requires to go by:
"filter_by": "coordinates:(59.1, 9.2, 100km)"
"sort_by": "coordinates(59.1, 9.2):asc"
And this finally creates outputs defining the geo_distance_meters on hits as:
"geo_distance_meters": {
"coordinates": 95432
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/Typesense/Documents.d.ts at the geo_distance_meters declaration around line 71, then compare it with the issue's coordinates example and the collection definition. Done means the type accepts the collection's actual geopoint field name, while retaining useful typing for the returned distance values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 76/100