get-convex / get-convex/geospatial

Filtering Bug

Open
#27 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
29
Forks
6
PR merge metrics
No merged PRs in 30d

Description

**Update**

I created an MRE here: https://github.com/nyoung697/geospatial-mre

Reproduce:

1) exec function `data/loadData` (no args)
2) exec function `data/get` args:

```
{
distance: 10000,
point: { latitude: 50.9753869, longitude: -114.0897771 },
weekdays: [3],
timeFilter: { start: 1140, end: 1150 },
}
```

**Change the end time to 1160, there will be 0 results returned...**

---

The sortKey doesn't work...

I've loaded about 2500 meetings into the database and have the sortKey set as the startTime in minutes since midnight.

I am trying to query all meetings nearby that start between a certain time frame:

```
let cursor: string | undefined = undefined;
const candidates: GeospatialResults = [];

do {
const { results, nextCursor } = await geospatial.query(
ctx,
{
limit,
shape: { type: "rectangle", rectangle },
filter: (q) =>
q
.gte("sortKey", timeFilter.start)
.lt("sortKey", timeFilter.end)
.in("weekday", weekdays),
},
cursor,
);

candidates.push(...results);
cursor = nextCursor; // stop when nextCursor is undefined/null
} while (cursor);
```

I can execute:

```
{
distance: 10000,
point: { latitude: 50.97537, longitude: -114.090383 },
weekdays: [3],
timeFilter: { start: 1140, end: 1150 },
limit: 5
}
```

And I will get back the 3 meetings nearby that start at 7pm... However, if I change the end time to 1160 or 2500 or whatever value that is higher than that, I get 0 results back...

I can search the points and see that the sortKey is correct and it falls between that range.

If I remove the filtering by sortKey, the result will come back.

I have tried this with both the `.query` and `.nearest` functions. I have tried changing the limit, and adding/removing other filters.

I have no idea what is happening here... The filtering seems to be quite buggy.

Contributor guide

Open the contributing guide

Research direction

Start by running the linked geospatial MRE, using data/loadData and data/get with the documented sortKey, weekday, and timeFilter values. Compare geospatial.query and nearest behavior as the end time changes; done means the expected nearby meetings are returned for valid sortKey ranges and the filtering behavior is covered by a reproducible check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.