Hello,
Sort appears to be broken for us:
We are passing in:
sort: { 'data.publishDate': -1 },
as an option for:
const getModels = (
page = 0,
perPage = 50,
items: any[] = [],
): Promise<QueryResultForSchema<S, F>[]> =>
builder
.getAll(schema.name, {
fields: fields?.join(','),
options: {
...options,
noTargeting: true,
offset: page * perPage,
},
query,
limit: perPage,
})
.then(response => {
const nextItems = items.concat(response)
return response.length < perPage || nextItems.length >= limit
? nextItems
: getModels(page + 1, perPage, nextItems)
})
Looping over the results gives us:
data.publishDate: 1683529200000 idx: 0 data.title: What Is A ...
data.publishDate: 1675756800000 idx: 1 data.title: How To Fil...
data.publishDate: 1675173600000 idx: 2 data.title: New Survey...
data.publishDate: 1673359200000 idx: 3 data.title: Embrace Pe...
data.publishDate: 1636520400000 idx: 4 data.title: Pawlicy Ad...
data.publishDate: 1616169600000 idx: 5 data.title: When Is Pe...
data.publishDate: 1642431600000 idx: 6 data.title: Synchrony ...
data.publishDate: 1652187600000 idx: 7 data.title: Pawlicy Ad...
data.publishDate: 1655303400000 idx: 8 data.title: Pawlicy Ad...
You can see that it starts to break on the last 2. We saw a similar behavior when trying to:
sort: {'data.title': 1},
Giving us mostly-correct:
data.publishDate: 1638259200000 idx: 25 data.title: Is Pet Ins...
data.publishDate: 1644220800000 idx: 26 data.title: Do Indoor ...
data.publishDate: 1647500400000 idx: 27 data.title: Does Car I...
data.publishDate: 1645776000000 idx: 28 data.title: Does Free ...
data.publishDate: 1646208000000 idx: 29 data.title: Does Insur...
data.publishDate: 1649746800000 idx: 30 data.title: Does Rente...
data.publishDate: 1650006000000 idx: 31 data.title: Dog Insura...
data.publishDate: 1648018800000 idx: 32 data.title: Is AARP Pe...
data.publishDate: 1644566400000 idx: 33 data.title: Dog Life I...
data.publishDate: 1566320400000 idx: 34 data.title: FAQ: Pet I...
data.publishDate: 1646035200000 idx: 35 data.title: Is Fetch P...
data.publishDate: 1660546800000 idx: 36 data.title: Can You Ge...
data.publishDate: 1628492400000 idx: 37 data.title: Is Healthy...
data.publishDate: 1643097600000 idx: 38 data.title: How & Wher...
data.publishDate: 1640246400000 idx: 39 data.title: How & Wher...
data.publishDate: 1638259200000 idx: 40 data.title: How & Wher...
You can see while most of the titles are correctly sorted, there’s a couple of “Is …”
which are spaced around. We believe this output is consistent.
We’d appreciate any assistance that will let us avoid having to sort on our servers.
Thanks!