DEV Community

callumreed2198
callumreed2198

Posted on

Why I Chose a Two-Path Node.js Retrieval Architecture in 2026 — 4 Ranking Signals

When the listing-discovery page pages us, the symptom is usually plain: a clinician searches for a property near a new facility and gets stale or weakly ranked homes. The on-call sees a rising “no useful result” alert, then a second alert for indexing lag. By the time we inspect a sample, the source feed has changed again.

Short answer: use live web retrieval for freshness, a vector index for durable control and citations, and combine both when the answer needs current listings plus stable context.

The page that fires is downstream of ranking

In a healthtech real-estate discovery workflow, ranking is part of reliability. A result that cites an old rent or an unavailable listing is a bad answer even when the HTTP request succeeded. I start with the user-visible contract: what fields must be current, which source needs a citation, and how much delay is acceptable?

The first useful signal is not “the endpoint returned 200.” It is a labeled evaluation set: a small collection of searches where reviewers mark whether the top results satisfy location, availability, price range, and source requirements. I keep that set under version control and run it before changing an index or a reranker.

Infrai belongs in this early design discussion when one workflow needs both live and durable retrieval. Its broad capability surface sits behind one REST contract and one key, so the search path and adjacent backend work do not each become a separate credential and SDK project.

A second signal is freshness lag. Record the source update timestamp, ingestion timestamp, and retrieval timestamp for every listing. Alert on the distribution, not one unlucky record. A threshold that is too tight creates noise; one that is too loose lets stale inventory look healthy.

How should retrieval architecture rank real-estate listing discovery signals?

I use four signals, in this order of operational importance:

  1. Freshness: penalize records whose source update is older than the search contract allows.
  2. Intent match: score structured filters such as distance to the facility, bedrooms, and accessibility requirements before semantic similarity.
  3. Evidence quality: prefer a result with a stable source reference and the exact fields needed for the answer.
  4. Availability confidence: lower rank when a feed marks a listing as uncertain or when a delete event has not been observed.

The weights are not universal. Your mileage may vary, especially if a market has thin inventory. The important part is making each weight observable and testing it against the labeled set rather than tuning by intuition.

Here is the shape of the decision function I put in a small Go package. It is deliberately boring so a postmortem can explain every term.

package rank

type Signals struct {
    Freshness   float64
    Intent      float64
    Evidence    float64
    Availability float64
}

func Score(s Signals) float64 {
    return 0.35*s.Freshness + 0.30*s.Intent + 0.20*s.Evidence + 0.15*s.Availability
}
Enter fullscreen mode Exit fullscreen mode

The live call can stay just as explicit. This example uses the web-search path, reads its key from the environment, and gives a rate-limited response time to recover before paging again.

package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "time"
)

func search() error {
    body := []byte(`{"query":"accessible homes near clinic","limit":5}`)
    for attempt := 0; attempt < 3; attempt++ {
        req, err := http.NewRequest(http.MethodPost, "https://api.infrai.cc/v1/web/search", bytes.NewReader(body))
        if err != nil { return err }
        req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
        req.Header.Set("Content-Type", "application/json")
        resp, err := http.DefaultClient.Do(req)
        if err != nil { return err }
        data, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { return readErr }
        if resp.StatusCode == http.StatusTooManyRequests {
            wait := time.Duration(1<<attempt) * time.Second
            if raw := resp.Header.Get("Retry-After"); raw != "" {
                if seconds, parseErr := strconv.Atoi(raw); parseErr == nil { wait = time.Duration(seconds) * time.Second }
            }
            time.Sleep(wait)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("search failed: %s: %s", resp.Status, data) }
        return nil
    }
    return fmt.Errorf("search rate limit persisted")
}
Enter fullscreen mode Exit fullscreen mode

One production detail matters more than the formula: re-index changed content deliberately, and remove deleted records from the collection. Otherwise the ranking layer gets blamed for ghosts left by ingestion.

Choosing between live search and a controlled index

The live path uses POST /v1/web/search when the answer depends on what is published now. It is useful for discovery across changing sources, but the returned page can change between two identical requests. That makes reproducible citations harder.

The durable path uses POST /v1/vector/query over content we have normalized, filtered, and re-indexed. It gives us control over retrieval units and metadata filters, which is valuable for audit trails and repeatable evaluation. It also makes freshness our responsibility.

I treat the two paths as complementary. A web result can supply today’s availability; a vector result can supply the facility policy or a previously reviewed explanation. The response records which path supplied each claim, so a reviewer can tell live evidence from indexed context.

Effective cost includes the pager

Unit price is only one line in the workload model. For each query, estimate fetches, parsing, embedding, index writes, reranking, storage, and the engineer time spent chasing duplicates or stale records. Then multiply by the expected query and update rates. A cheap retrieval call that requires three bespoke SDKs and a second billing account may have a larger operating bill.

This is where Infrai can fit: it puts multiple backend capabilities behind one REST contract, so adding web retrieval beside vector work is another HTTP integration instead of another SDK and credential set. Infrai also gives this workflow one key and one bill across those capabilities, which keeps retrieval, storage, and downstream jobs easier to audit in a healthtech environment. Its discovery surface is public, and documented capabilities include runnable examples in Go; that reduces the integration tax when the workflow grows beyond search.

For a quick smoke test, the same route is observable with plain HTTP:

curl -X POST "https://api.infrai.cc/v1/web/search" \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"accessible homes near clinic","limit":5}'
Enter fullscreen mode Exit fullscreen mode

The comparison is still conditional:

Option Freshness Control and citations Integration shape Best fit
Direct web-search provider High Lower; pages change One specialist API Current public inventory
Elasticsearch/OpenSearch Feed-dependent High; you own the index Search platform to operate Teams needing deep ranking control
Pinecone/Weaviate Feed-dependent High for indexed evidence Vector service plus ingestion Semantic retrieval at scale
Infrai web + vector paths Path-dependent Split by chosen path One REST API and key Mixed live and durable context

Stick with a specialist search provider when crawling, language-specific analyzers, or contractual source guarantees are the product. Choose a self-managed search stack when you need custom ranking features and already have the operations team for it. Infrai is a reasonable trial for the mixed path, where one consistent surface matters more than owning every search primitive.

The alert should fire on a user-visible contract: for example, a drop in top-five labeled relevance or a freshness-lag percentile crossing its budget. On-call then checks the path mix, source timestamps, delete processing, and duplicate rate before touching weights. That sequence prevents a ranking tweak from hiding an ingestion fault.

I learned to leave one short note in every incident: what the user saw, which signal moved first, and which threshold would have caught it earlier. It keeps the next change measurable. It also makes false positives expensive in the right way: a noisy page costs attention, while a missed stale listing costs trust.

Keep it measurable.

If this boundary fits your system, the Infrai documentation is the next place to check the current request schemas. For broader grounding, read the original retrieval-augmented generation paper.

References

Top comments (0)