[Feature Request] Optionally include field types in facet_counts responses
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend-api-design, search
Direzione di ricerca
Inizia dalla costruzione della risposta delle facet in src/collection.cpp intorno alle righe 5440-5480, quindi confronta lo schema delle facet in openapi.yml intorno alle righe 3895-3920. Traccia il modo in cui le richieste normali e multi_search risolvono i campi facet, incluse le facet dinamiche, unite e di intervallo. Il lavoro è completato quando la risposta opt-in include il tipo di campo completo risolto, mentre le risposte predefinite e counts[].value rimangono invariati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe your feature request
Add an opt-in search parameter that includes each facet field's Typesense schema type in the corresponding facet_counts entry.
For example, a search request could specify:
{
"q": "*",
"query_by": "name",
"facet_by": "free_shipping",
"include_facet_field_types": true
}
The response would then include field_type:
{
"field_name": "free_shipping",
"field_type": "bool",
"counts": [
{
"value": "true",
"count": 1678
}
]
}
The exact parameter name is only a suggestion. The important behavior is:
- The parameter is disabled by default.
- When omitted or set to
false, the existing response remains unchanged. - When enabled, each
facet_countsentry includes the resolved Typesense schema type asfield_type. - The type should preserve the complete Typesense type, including array information, for example
bool,int32,int64,float,string,bool[], orint32[]. - For fields created through
autoor dynamic schema detection, the resolved concrete type should be returned rather thanauto. - This should work consistently for regular searches and
multi_search. - The existing
valueproperty should remain a string for backward compatibility.
This proposal does not require returning the complete collection schema. It only adds the type associated with each requested facet field.
Please describe your use-case for the feature request
Typesense currently serializes all facet values as strings, regardless of their schema type. For example, the following facet values are indistinguishable from the response alone:
- The boolean value
trueand the string value"true". - The integer value
123and the string value"123". - A scalar field and an array field containing the same value.
A client that dynamically builds filters from facet_counts therefore needs access to the collection schema to interpret each facet correctly and construct the appropriate filter expression.
The main motivation for this feature is to avoid requiring clients to separately load, cache and maintain the collection schema.
The current alternatives introduce several problems:
-
Additional requests
The client must call
GET /collections/:collectionbefore it can safely interpret facet values. This adds another request per collection or application lifecycle. -
Schema state management
The client must cache the schema, decide when to refresh it and maintain a mapping between every facet field and its type.
-
Race conditions
A cached or locally bundled schema can become stale after a schema update, dynamic field addition, reindex or collection-alias switch. A search response can then contain facets from the new schema while the client still interprets them using the old schema.
This can cause the client to construct an incorrect filter or parse a facet value using the wrong type. Coordinating schema changes with all deployed clients is especially difficult in browser and mobile applications.
-
Additional permissions
A typical browser search key only needs
documents:search. Retrieving the schema requires also grantingcollections:get, even though the client only needs the types of the facet fields present in the search response. -
Dynamic clients
Generic search clients, dashboards and UI component libraries may not know the collection schema at build time. Returning the type together with each facet would make the facet response self-describing without sending the complete schema.
Including field_type in the same response would guarantee that the type metadata and facet data come from the same search execution and schema state, eliminating this class of synchronization race conditions.
Because multi-search requests can return many facet groups, the feature should be opt-in. Clients that do not need type information would retain the current response size and behavior.
Describe alternatives you've considered
-
Fetch and cache the collection schema
This works, but requires an additional request, additional API-key permissions, cache invalidation and synchronization with schema or alias changes.
-
Bundle or hard-code the schema in the client
This duplicates server-side schema state and requires coordinated deployments. It is vulnerable to race conditions when the server schema changes before all clients have been updated.
-
Infer the type from the facet value
This is not reliable because all facet values are strings.
"true"could be either a boolean or a string, and"123"could be an integer, float or string. It is also impossible to determine whether the underlying field is a scalar or an array. -
Infer numeric fields from
statsThis does not cover boolean, string or array distinctions and makes clients dependent on incidental response properties rather than explicit schema metadata.
-
Return facet values using native JSON types
Changing
valuefrom a string to a boolean or number would be a breaking response-contract change. Adding an opt-infield_typeproperty preserves the existing representation and client compatibility.
Additional context
Typesense already looks up the facet field in the search schema and converts integer, float and boolean facet values to strings when constructing the response:
The current API specification defines counts[].value as a string and does not expose the underlying field type:
Related issues demonstrate the current string representation but do not request type metadata:
- Boolean facet values: https://github.com/typesense/typesense/issues/976
- Floating-point facet serialization: https://github.com/typesense/typesense/issues/593
For joined or referenced facets, field_type should ideally represent the type of the resolved facet field in the referenced collection. For numerical range facets, it should represent the underlying numerical field type even though the returned range labels remain strings.
- Lingua principale
- C++
- Stelle
- 27.1k
- Fork
- 1k
- Merge medio
- 4g 4h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typesense/typesense
-
pre-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
typesense/typesense#3070 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Bundled OpenSSL is pinned to 3.0.5, and the 3.0 branch reached end of life on 7 September 2026Forse già presa @mbkkong l’ha presa 40 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
Match scoring loop performs a heap allocation per window iteration for every candidate documentApertafeature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
[Feature Request] Skip regenerating auto-embeddings on update when the source fields haven't changedApertafeature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
typesense/typesense#2932 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di typesense/typesense
Issue simili
-
Issue-Bug Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/winget-cli#6645 ·
I maintainer di solito rispondono entro 2 giorni
-
cleanup help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ESPresense/ESPresense#2602 ·
I maintainer di solito rispondono entro 1 giorno
-
devex good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
artifact:simulation-scenario domain:physics good first issue help wanted role:validation testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 3 giorni