Picsha AI

Search Infrastructure

Digital Asset Managers often struggle with metadata. Expecting humans to painstakingly tag every uploaded image is an archaic approach.

The moment a media file is ingested, it is enqueued to Picsha's asynchronous processing workers, which automatically extract structural analysis from the image via AWS Rekognition and visual embeddings via Amazon Nova multimodal embeddings, streaming the result into our underlying OpenSearch Vector Database.

Standard Search (Keyword)

By default (mode: "standard"), a search is a fast text query over each asset's file names, tags, custom metadata, AI labels, named faces, AI descriptions and EXIF fields. No language model is involved: the words you send are the words that have to match, so it answers in milliseconds and behaves the same way every time.

Every word must match, though not in the same field, and the last word is also matched as a prefix on tags, labels, object names and file names, so a search box can call it on every keystroke.

Query syntax

The query string understands a small, conventional syntax. Nothing you type is a syntax error: unbalanced quotes or a dangling operator degrade to a plainer query instead of failing, so search-as-you-type keeps working mid-keystroke.

QueryMatches
apple peachapple AND peach (every word must match)
apple | peachapple OR peach
apple -peachapple, but not peach
"118th congress"the phrase, words in that order
wing*words starting with wing
(apple | peach) -piegrouping
#scenicsexactly the tag #scenics (see Hashtags below)
  • Every word must match, but not necessarily in the same field: cats in a tag and dogs in an AI label satisfy cats dogs.
  • -, + and | only act as operators where they stand alone or start a word. NY-04 searches as text.
  • The last word of the query is also matched as a prefix on tags, labels, object names and file names, so wing already finds wings. You do not need to add * for the word being typed.
  • An @ in front of a word or a quoted phrase is ignored (@"Gillen Laura"), so the name behind it is searched as text.
  • Fuzzy matching (~), proximity and slop are not supported.

NOTE

Mixing | with - or + in one query without parentheses does not follow textbook precedence: clauses fold left to right, so a | b c means (a | b) c. Use parentheses whenever a query mixes operators.

Hashtags

A bare word is a full-text search; a word with a # in front is a lookup on the asset's tags alone.

QueryMatches
scenicsanything that mentions scenics: a tag, an AI label, a file name, an AI description, custom metadata
#scenicsonly assets tagged #scenics (or scenics)
#"118th congress"the one multi-word tag
#scentags starting with scen, as you type
#lava (trailing space)only the tag #lava; without the space, #lava flow matches too
  • Tag matching is exact and case-insensitive: #Hawaii finds #hawaii, and neither finds #hawaii2026.
  • A tag stored without the # matches too, so older libraries need no re-tagging.
  • The last #tag in the query is matched as a prefix while it is being typed. A space after it finishes it, so send #lava for exactly that tag; #lava* asks for the prefix explicitly.
  • Operators apply to tags as to words: #zoo | #hawaii, -#hawaii zoo, (#zoo | #jaws) -#hawaii, #scenics beach (the tag and the word).
  • #tag results are always a subset of the bare word's results.

AI Search (Hybrid Mode)

Passing mode: "ai" to our Search endpoint unleashes our most powerful API abstraction.

When you query our servers with conversational NLP (e.g. "Show me the photos of dogs running on the beach from last Tuesday"):

  1. Agentic Parsing: We route the string through an LLM layer that parses actionable metadata constraints (e.g., isolating last Tuesday into a literal timestamp boundary).
  2. Text-to-Image Embedding: The rest of the semantic request ("dogs running on the beach") is converted into a high-dimensional multimodal vector array.
  3. k-NN Vector Execution: We perform a blistering k-NN (k-nearest neighbors) query against your Organization's dedicated vector space in OpenSearch.

Strict Intent Filtering (Methodology)

To prevent multimodal embeddings from surfacing false positives (e.g., searching for "Bill laughing" and getting dozens of unrelated but highly scored laughing people), our Agentic Parsing layer enforces strict, absolute metadata constraints prior to executing the vector search:

  • Visual Concepts & Colors: Handled purely by vector distances. If you search for "pink flowers", no explicit filters are applied. The embedding inherently calculates and surfaces visually matching images.
  • Human Names (Entities): Treated as non-negotiable hard filters. If the parsing layer detects a human name (e.g., "Hello bill"), it interprets the goal as a definitive entity search. It generates an explicit OpenSearch filter demanding that the asset must possess a match inside the ai.faces or user.tags indices.
  • Methodology Impact: While this guarantees exceptionally high accuracy for photographic face retrieval, it means text-heavy documents containing a person's name buried in a paragraph summary (like an ai.description) will be intentionally dropped from AI search pools unless the asset is explicitly tagged.

Search Thresholds

AI Search returns hits ordered by relevance score (matchScore). To prevent hallucinated matches from muddying the results, our backend inherently filters out any assets falling below a relevance threshold (default 0.45). An asset whose file name or a tag matches the query as a phrase is always kept.

When building applications, you can dictate this exact cutoff threshold explicitly:

{
  "query": "corporate headshots with blue backgrounds",
  "mode": "ai",
  "threshold": 0.65 
}

matchScore is relative to the search, not a confidence. The visual (vector) and word (text) matches are each normalized across the hits of that one search and then combined, so the closest visual match always lands at about 0.6, however good or poor a match it really is. Use matchScore to rank results. A threshold trims the weak end of a list, but it cannot tell a query with a good answer from a query with no answer at all; that is what minSimilarity is for.

Similarity Floor (minSimilarity)

minSimilarity is an absolute floor on how visually similar an asset must be to the query. It is measured on the raw similarity, before scores are normalized, so a query with nothing relevant in scope returns nothing instead of its least-bad asset.

FieldTypeNotes
minSimilaritynumber, -1–1Optional. ai mode only; ignored in standard mode. The cosine similarity between the query's embedding and the asset's.
  • Assets below the floor are dropped from the visual matches. Word matches are unaffected: an asset whose labels, tags, file name or description match the query's words is still returned.
  • With minSimilarity set and no threshold, the threshold defaults to 0. Every visual match left has already cleared the floor, and normalization would otherwise put the weakest of a few genuine matches near zero, where the usual default would drop it. An explicit threshold still applies.
  • matchScore on the results is still the relative score described above.
POST /v1/search?limit=40
{
  "query": "first dance",
  "mode": "ai",
  "assetIds": ["7f3c2a10-5b8e-4d21-9c6f-2e1a0b9d8c47", "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"],
  "minSimilarity": 0.2
}
{
  "results": [
    { "id": "7f3c2a10-5b8e-4d21-9c6f-2e1a0b9d8c47", "matchScore": 0.6, "originalName": "first-dance-0412.jpg", "mimeType": "image/jpeg" }
  ],
  "pagination": { "page": 1, "limit": 40, "total": 1 }
}

The same request for "dog", in a gallery with no dogs, returns "results": [] and a total of 0. Without minSimilarity it would return the gallery's closest photo at 0.6.

Picking a value

The right floor depends on the embedding model. With Picsha's default Amazon Nova multimodal embeddings, measured on a wedding gallery:

QueryBest similarity in the galleryCorrect photo?
Subjects not in the gallery (dog, zebra, car, Christmas tree)0.06 – 0.16none to find
kiss, beach, rings, black and white, candles0.24 – 0.33yes
veil, bouquet, first dance0.37 – 0.50yes

0.2 separates the two groups and is the recommended starting point. Raise it for stricter results, lower it if real matches go missing. A floor tuned on one embedding model does not carry over to another, so re-check it if your organization uses different embeddings.

Advanced Filters

In addition to semantic queries, you can supply structured filters in the advancedFilters (or filters) block to limit search scope. These filters are applied prior to vector ranking:

  • Date Ranges:
    • addedAfter / addedBefore: Boundaries for the ingestion timestamp (e.g. "now-30d").
    • capturedAfter / capturedBefore: Boundaries for the EXIF photo capture timestamp.
  • AI Metadata:
    • face: Match a recognized face identity (e.g. "John Doe").
    • object: Match an auto-detected item label (e.g. "dog").
    • place: Match reverse-geocoded location strings (e.g. "Denver").
  • Media Context:
    • type: Match the MIME type prefix (e.g. "image" or "video"), or a list of prefixes (["image/png", "image/jpeg"]) any of which may match.
    • style: Match custom aesthetic or UI categories (e.g. "STANDARD", "FILM", "URL").
  • Custom Metadata:
    • metadataField / metadataValue: Search a specific metadata field (e.g., legacy fields like "pictures_meta_subject.value", or custom fields in user.custom).
    • minRating: Integer 1–5. Only assets whose metadata.rating is at least this many stars (so 3 means three stars or better).
    • metadata: Object of exact matches on custom metadata keys, e.g. {"asset_status": "Retired"}. Every key must match. Unlike metadataField, several keys can be combined. A key may list several values ({"asset_visibility": ["@all", "@sales"]}), any of which matches; on a key that stores an array, any stored element may match any listed value (up to 200 values per key).
    • metadataRange: A range per custom metadata key, for dates stored as YYYY-MM-DD, e.g. {"rights_expiry": {"gte": "2026-10-01", "lte": "2027-03-31"}}. Either bound may be left out; keys are ANDed.
  • Alternatives:
    • anyOf: A list of up to 10 filter blocks, each with the same fields as advancedFilters itself (minus anyOf). An asset matches when it satisfies at least one block; the whole list is combined with the other filters. See the example below.

Example Filter Request

{
  "query": "corporate headshots",
  "mode": "ai",
  "advancedFilters": {
    "type": "image",
    "capturedAfter": "2026-01-01",
    "style": "STANDARD",
    "metadataField": "pictures_meta_subject.value",
    "metadataValue": "#special events"
  }
}

Example: alternatives with anyOf

{
  "query": "beach",
  "advancedFilters": {
    "type": "image",
    "anyOf": [
      { "metadata": { "asset_visibility": ["@sales"] } },
      { "metadata": { "asset_visibility": ["@all"], "approval": "approved" } }
    ]
  }
}

Images matching "beach" that are either visible to @sales, or visible to @all and approved. Inside a block the filters are ANDed; blocks are ORed with each other. The same metadata and anyOf filters are available on GET /v1/assets as JSON query parameters, so a listing and a search can apply one policy.

Scope

Search covers the same assets as GET /v1/assets: an organization-scoped API key searches the whole organization, and a personal key searches its own uploads. Trashed assets are never returned.

Limiting to Specific Assets

assetIds restricts the search to the listed assets, and excludeAssetIds leaves the listed assets out. Both narrow the scope itself, not just the returned page, so they apply to the hits, pagination.total and any facets alike, in both modes, and the total stays stable as you page.

POST /v1/search?page=1&limit=40
{
  "query": "beach",
  "assetIds": ["7f3c2a10-5b8e-4d21-9c6f-2e1a0b9d8c47", "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"],
  "excludeAssetIds": ["9b2e6c1a-7d43-4f0e-8a55-1c2d3e4f5a6b"]
}
  • Up to 10,000 ids each. An empty list means no restriction, the same as leaving the field out.
  • An id in both lists is excluded. Ids that do not exist or belong to another tenant are ignored.
  • Use assetIds to search inside an album or gallery whose membership your application already knows.

Request Body Reference

POST /v1/search takes the query and options in a JSON body, and page and limit as query parameters (?page=1&limit=40; limit=0 returns only the total and facets).

FieldTypeNotes
querystringThe search text. Standard mode follows the query syntax; AI mode takes natural language. May be empty when filters alone select the assets.
modestandard | aiDefault standard.
thresholdnumberAI mode. Minimum matchScore; default 0.45, or 0 when minSimilarity is set. See Search Thresholds.
minSimilaritynumber, -1–1AI mode. Absolute floor on visual similarity, e.g. 0.2. See Similarity Floor.
sortstringrelevance (default), added-desc, added-asc, created-desc, created-asc, name-asc, name-desc. created-* sorts by capture date, falling back to the upload date.
timezonestringIANA zone, e.g. America/New_York. Anchors relative dates such as "today" and "this week" to the user's day. The server's zone is used when omitted.
advancedFilters / filtersobjectStructured filters; see Advanced Filters.
facetsarrayUp to 10 distinct-value counts; see Facets.
assetIdsstring[]Only these assets can match; see Limiting to Specific Assets.
excludeAssetIdsstring[]These assets never match.

Facets (Distinct Values with Counts)

Add a facets array to any search request to get the distinct values of a field, with counts, over the same scope as the hits — the caller's organization, the text query (standard mode), and any advancedFilters. Use it to build filter sidebars, people/place pickers, tag clouds, or autocomplete without scanning your library.

POST /search?limit=0
{
  "query": "",
  "mode": "standard",
  "advancedFilters": { "capturedAfter": "now-30d/d" },
  "facets": [
    { "field": "faces",  "size": 1000, "order": "key" },
    { "field": "places", "size": 1000, "order": "key" },
    { "field": "tags" }
  ]
}
FieldTypeNotes
fieldstringfaces, labels, places, tags, mimeType, cameraMake, cameraModel, or metadata.<key> for one of your own custom metadata keys (below)
sizeint, 1–1000, default 50Maximum number of values returned
ordercount | keycount (default) = most frequent first; key = alphabetical

Up to 10 facets per request. Pass ?limit=0 to receive facets and the total without any hits.

{
  "results": [],
  "pagination": { "page": 1, "limit": 0, "total": 4312 },
  "facets": {
    "faces":  [{ "value": "Bill Bradley", "count": 41 }, { "value": "Sally Jones", "count": 17 }],
    "places": [{ "value": "New York, NY, USA", "count": 209 }],
    "tags":   [{ "value": "snow", "count": 12 }]
  }
}

facets is present only when requested. In AI mode with a semantic query, facets are computed over the filter scope (tenant + advancedFilters) rather than the ranked result set, because facets are counts, not rankings. Values are exact strings as indexed (case-sensitive).

NOTE

Facets are available from API version 1.0.78. Assets indexed before the upgrade appear in the faces, labels, places, and tags facets after the library's one-time reindex; mimeType and camera facets work immediately.

Facets on your own metadata keys

Any custom key you write with PATCH /assets/:id (metadata.<key>) can be faceted as metadata.<key>, from API version 1.0.128. The response uses the same name:

POST /search?limit=0
{ "query": "", "facets": [{ "field": "metadata.city", "size": 100, "order": "key" }] }
{
  "results": [],
  "pagination": { "page": 1, "limit": 0, "total": 555 },
  "facets": { "metadata.city": [{ "value": "Austin", "count": 40 }, { "value": "Washington", "count": 212 }] }
}

A key is letters, digits, _ and -, in segments joined by dots (city, picture.category.style), up to 128 characters. Values come back as strings whatever the key holds: a numeric key such as an f-number gives "11", a yes/no key "true" and "false", a date key an ISO timestamp. A key the index has not seen yet answers with an empty list. Strings longer than 512 characters are never facet values, so keep faceted keys short and categorical; a multi-valued key counts each stored value once per asset.

Similar Assets

Search answers "find assets matching these words". Similar assets answers "find assets that look like this one". Every asset ingested with vectorize: true (the default) has an embedding in the vector index, and GET /assets/:id/similar returns the nearest neighbours of that embedding, most similar first.

GET /assets/5e92fe62-40a4-42fe-aa99-0a2d84a91cb7/similar?limit=12
ParameterTypeNotes
limitint, 1–50, default 12Number of matches returned
minScorenumber, 0–1Optional. Drops matches scoring below it. Omitted, the nearest limit are returned whatever they score
{
  "assetId": "5e92fe62-40a4-42fe-aa99-0a2d84a91cb7",
  "results": [
    { "id": "123e4567-e89b-12d3-a456-426614174000", "matchScore": 0.91, "originalName": "harbor-at-dusk.jpg", "mimeType": "image/jpeg" }
  ],
  "total": 1
}

The embedding is read from the index, so no model is called at request time. The asset itself and trashed assets are never returned, and the scope is the caller's tenant, as in search.

Filtering the Matches

POST /assets/:id/similar takes limit and minScore in the body, plus the advancedFilters and excludeAssetIds that POST /search accepts. Use it to compare pictures only with pictures, or to keep the matches within what your own user may see.

POST /assets/5e92fe62-40a4-42fe-aa99-0a2d84a91cb7/similar
{
  "limit": 24,
  "advancedFilters": { "type": "image", "metadata": { "asset_status": "Active" } },
  "excludeAssetIds": ["9b2e6c1a-7d43-4f0e-8a55-1c2d3e4f5a6b"]
}

The filters are applied inside the nearest-neighbour search. You receive the limit nearest assets of the filtered scope, not a filtered remainder of the unfiltered nearest.

Assets Without an Embedding

An asset that was ingested with vectorize: false, or is still processing, has nothing to compare. The response is an empty list with a reason, not an error:

{ "assetId": "5e92fe62-40a4-42fe-aa99-0a2d84a91cb7", "results": [], "total": 0, "reason": "no-embedding" }

NOTE

Similar assets are available from API version 1.0.94.