Stevenic / vectra

Vectra is a local vector database for Node.js with features similar to pinecone but built using local files.
MIT License
321 stars 29 forks source link

Adding "/" entry breaks the index #40

Closed adaboese closed 5 months ago

adaboese commented 5 months ago
it('finds the most similar URL entry', async () => {
  const searchIndex = await createSearchIndex('test');

  await searchIndex.addItem('/', {
    original: '/',
  });

  await searchIndex.addItem('/foo', {
    original: '/foo',
  });

  await searchIndex.addItem('/bar', {
    original: '/bar',
  });

  const result = await searchIndex.findNearestItem('/bar');

  expect(result.item.metadata).toStrictEqual({
    original: '/bar',
  });
});

In this example, score becomes NaN.

I worked around this by simply excluding / entries from the index, but it was a bizarre issue to debug.

adaboese commented 5 months ago

Issue in my code.