hypercore-protocol / p2p-indexing-and-search

Getting started with P2P indexing and search using the Hypercore Protocol
MIT License
82 stars 16 forks source link

possible bug in solution 12 of the tutorial #7

Closed jaredatron closed 3 years ago

jaredatron commented 3 years ago

This solution https://github.com/hypercore-protocol/p2p-indexing-and-search/blob/main/solutions/12/index.js#L41 suggests that a query of { gt: '35/', lt: '36/' } would yield all secondary index records that start with "${n}/" where n is between 35 and 36. This is not the result I am seeing when I run this code. I get all secondary index records that start with '35'.

console.log( new Set(resultSet.map(r => r.key.split('/')[0])) )
Set(27) {
  '35',
  '350',
  '3504',
  '3507',
  '351',
  '3518',
  '352',
  '3522',
  '353',
  '3533',
  '354',
  '3549',
  '355',
  '3554',
  '3555',
  '3556',
  '356',
  '3562',
  '3563',
  '357',
  '3575',
  '358',
  '3585',
  '359',
  '3592',
  '3593',
  '3595'
}
jaredatron commented 3 years ago

facepalm