Skip to main content
Glama
SearchScorer.test.ts1.19 kB
import { describe, expect, it } from 'vitest'; import { scoreAndRank } from '@/services/search-utilities/SearchScorer.js'; describe('SearchScorer', () => { it('ranks exact domain matches highest', () => { const query = 'olivebranchclinic.org'; const results = [ { id: { record_id: '1' }, values: { name: 'Springfield Clinic', domains: ['springfieldclinic.com'], }, }, { id: { record_id: '2' }, values: { name: 'Olive Branch Clinic', domains: ['olivebranchclinic.org'], }, }, ]; const ranked = scoreAndRank(query, results); expect(ranked[0].values.domains).toEqual(['olivebranchclinic.org']); }); it('ranks exact name matches over partial token matches', () => { const query = 'Teara Young'; const results = [ { id: { record_id: '1' }, values: { name: 'Connor Young' } }, { id: { record_id: '2' }, values: { name: 'Teara Young' } }, { id: { record_id: '3' }, values: { name: 'Francine Young' } }, ]; const ranked = scoreAndRank(query, results); expect(ranked[0].values.name).toBe('Teara Young'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server