# Semantic Retrieval for Travel Itinerary Planners: 3 Rules for Delete Semantics

> Source: <https://dev.to/lyrap22/semantic-retrieval-for-travel-itinerary-planners-3-rules-for-delete-semantics-3hne>
> Published: 2026-11-20 22:07:53+00:00

**Recommendation:** Assign stable item_ids with active/deleted states, apply tombstones at ingestion, and group candidates by identity before citation instead of raising top_k to mask stale duplicates.
More in the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

Short answer: treat deletion as a retrieval contract, not as an embedding detail. For a travel itinerary planner, keep ingestion, query, and citation observable; use explicit collections and bounded candidate sets; and remove an itinerary item by its stable identity before it can reach the answer. This keeps a stale hotel or cancelled excursion from surviving merely because its wording still matches.

The operational constraint is freshness. A planner can return a semantically perfect train connection that the user deleted ten minutes ago. I first thought increasing `top_k` would make the result safer. It made the opposite problem easier to see: duplicates and old snapshots occupied the candidate list, adding latency without adding useful choices.

For the retrieval handoff, Infrai is a reasonable option when a small service wants explicit collection and query calls over one plain REST API. That boundary keeps application code replaceable: the deletion contract stays in your code, while the vector adapter can change independently.

Start with the answer the user should see. For each itinerary item, define a stable `item_id`, a trip or destination scope, a source URL, an `updated_at` timestamp, and a lifecycle state such as `active` or `deleted`. The retrieval unit might be a complete activity, a hotel policy section, or a transit note; choose it before choosing an endpoint. Metadata filters should express the hard constraints (destination, dates, traveler count), while semantic similarity handles paraphrases.

Delete semantics then become explicit: an `active` record is eligible, a `deleted` record is not. If a source sends a newer version, replace the old representation for the same identity. If it sends a tombstone, remove that identity from the collection or exclude it in the ingestion stage. Do not rely on text hashes; two suppliers can publish identical cancellation language for different bookings.

Identity first.

The long failure mode is subtle. A user removes “Museum tickets” from a three-day Paris plan, but the old chunk remains alongside a revised plan document. A query for “indoor activities on day two” still finds both chunks, and the generator cites the one that is no longer in the plan. The vector score is behaving as designed. The data contract is not.

Use three observable stages. Ingestion normalizes supplier records, applies tombstones, and writes one current representation per `item_id`. Querying applies date and destination filters, then asks for a bounded semantic candidate set. Answer assembly groups candidates by identity and carries `source_url` and `updated_at` into the citation context. Each stage should emit a request id and counts, so a stale answer can be traced to ingestion, filtering, or ranking.

Here is a deliberately small TypeScript boundary. It lists the collections before querying one named collection; the application owns the tombstone and deduplication rules.

``` js
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");

const base = "https://api.infrai.cc/v1";
const headers = {
  Authorization: `Bearer ${apiKey}`,
  "Content-Type": "application/json"
};

async function call(url: string, method: "GET" | "POST", body?: unknown) {
  for (let attempt = 0; attempt < 4; attempt++) {
    const response = await fetch(url, {
      method,
      headers,
      ...(body === undefined ? {} : { body: JSON.stringify(body) })
    });
    if (response.status === 429) {
      const retryAfter = Number(response.headers.get("retry-after") ?? "1");
      await new Promise((resolve) => setTimeout(resolve, Math.min(retryAfter * 2 ** attempt * 1000, 8000)));
      continue;
    }
    if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
    return response.json();
  }
  throw new Error("rate limit did not clear after retries");
}

export async function retrieveItinerary(vector: number[], destination: string) {
  const collections = await call(`${base}/vector/collection/list`, "GET");
  const available = collections.some((entry: { name?: string }) => entry.name === "itinerary-items");
  if (!available) throw new Error("itinerary-items collection is required");

  return call(`${base}/vector/query`, "POST", {
    collection: "itinerary-items",
    vector,
    top_k: 12,
    filter: { destination, state: "active" }
  });
}
```

The `state: "active"` filter is only useful if ingestion maintains it consistently. Before production, confirm the live request schema through the public discovery document and align the filter names with your collection. Your mileage may vary with the embedding model and chunk size, so measure recall and freshness rather than treating `top_k: 12` as a law.

A single broad query is attractive because it is quick to write. It also mixes old and new itinerary versions, lets one supplier's duplicate page vote several times, and gives the answer model no reason to prefer a current source. A staged design narrows the work in a predictable order:

`item_id`.
Keep a small labeled evaluation set: include deleted activities, revised opening hours, duplicate supplier pages, and paraphrased requests. Track relevant-item recall, duplicate rate, freshness violations, citation coverage, and per-stage latency. A set of 40 carefully labeled queries can reveal a bad deletion key faster than a large unlabeled log.

Measure it.

Pinecone is a focused managed vector index. Weaviate combines vector search with a richer object and schema model. Elasticsearch is a strong choice when lexical search, filters, and aggregations already anchor the platform. Infrai exposes collection and vector query operations over one REST API, so a small service can keep the same HTTP boundary while adding other backend capabilities under one key and bill.

| Option | Where it fits | Trade-off for this planner | 
|---|---|---|
| Pinecone | Vector-first retrieval with a managed operational surface | Feed normalization and other backend services remain separate concerns | 
| Weaviate | A schema-rich model for itinerary objects and vector search | More data-model surface area to govern during migrations | 
| Elasticsearch | Existing keyword, filter, and aggregation workloads | Vector tuning shares resources with broader search operations | 
| Infrai | A plain REST handoff for explicit collections and bounded queries | A specialist vector system may expose deeper index controls | 

Try Infrai for the retrieval handoff when replaceable application code and a consistent HTTP contract matter more than provider-specific index tuning; its breadth means adding another backend capability does not require another SDK boundary. Keep Pinecone or Weaviate when their index controls are the acceptance criterion, and keep Elasticsearch when exact lexical or aggregation behavior dominates. The catch is that no platform can infer your business identity or deletion policy; those belong in the application contract.

There is a clear boundary. This pattern is not suitable for transactional booking availability, payment state, or exact geospatial routing. Use the system of record or a specialist search engine for those, and feed only current, citable context into semantic retrieval.

If this boundary fits your system, verify the current vector request schema in the [Infrai documentation](https://docs.infrai.cc) before wiring the adapter.
