February 2, 2024

How Hornet Uses Metadata Indexing to Help Users Find the Perfect Match

Phil Miesle
Phil MiesleDeveloper Advocate
How Hornet Uses Metadata Indexing to Help Users Find the Perfect Match
async function findWithinRadiusUsingText(
    text: string, k: number, radius: number, lat: number, lon: number
): Promise<Amenity[]> {
    const vectorStore = await astra.getVectorStore();

    const filter = { 
        name: "GEO_DISTANCE(coords,?)",
        operator: "<=",
        value: [new Float32Array([lat, lon]), radius] 
    };

    const results = await vectorStore.similaritySearchWithScore(text, k, filter);

    const documents = results.map(result => result[0]);
    const scores = results.map(result => result[1]);

    const amenitiesMap = processAmenityResults(documents, scores);

    return Array.from(amenitiesMap.values());
}
Discover more
Vector Search
Share

One-stop Data API for Production GenAI

Astra DB gives JavaScript developers a complete data API and out-of-the-box integrations that make it easier to build production RAG apps with high relevancy and low latency.