Querying Firestore documents by nested key-value in an array field using Python
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
L'issue non indica file o test del repository. Inizia esaminando il comportamento delle query di Firestore per array-contains e i campi annidati insieme all'API FieldFilter di Python; il lavoro è completato quando si determina se questo predicato è supportato e si documenta l'approccio di query appropriato o la limitazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
I'm working with Firestore in Python and have a data query challenge I'm hoping to get some advice on.
My documents in Firestore are structured as follows:
{
"key1": "value1",
"key2": {
"subKey1": [
{
"arrayKey1": "arrayValue1",
"arrayKey2": "arrayValue2"
},
{
"arrayKey3": "arrayValue3",
"arrayKey4": "arrayValue4"
}
],
"subKey2": "subValue2"
}
}
My goal is to query documents where the value of arrayKey1 within the subKey1 array matches a specific value (for example, target_arrayValue1), regardless of the arrayKey2 in the same dictionary.
Here's an example of what my query currently looks like:
docs = query.where(
filter=FieldFilter(
"key2.subKey1",
"array_contains",
{
"arrayKey1": "target_arrayValue1",
"arrayKey2": "arrayValue2"
}
)
).stream()
This approach, however, requires a full match of the dictionary, which is not ideal.
Describe the solution you'd like
My “ideal” code would do something like this:
docs = query.where(
filter=FieldFilter(
"key2.subKey1.0.arrayKey1",
"==",
"target_arrayValue1"
)
).stream()
Is there an appropriate way to structure my query to achieve this? Any insights or examples would be greatly appreciated! Thanks in advance.
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 359
- Merge medio
- 5g 6m
- PR unite (30g)
- 2
Guida per i contributori
Apri 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 firebase/firebase-admin-python
-
api: remoteconfig
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
firebase/firebase-admin-python#957 · 1 commento ·
-
api: database type: feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
firebase/firebase-admin-python#978 · 1 commento ·
-
[FR] Support VERIFY_AND_CHANGE_EMAIL in generate_email_action_link (parity with firebase-admin-node) Apertaapi: auth
firebase/firebase-admin-python#949 · 2 commenti · 1 reazione · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 43/100
firebase/firebase-admin-python#945 · 1 commento · 1 reazione ·
Tutte le issue di firebase/firebase-admin-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
learningequality/ricecooker#747 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
run-llama/llama_index#23199 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
KhronosGroup/glTF-Blender-IO#2769 ·