Query sub array
- Linguagem predominante
- Go
- Estrelas
- 31
- Forks
- 26
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
Hi !
I am trying to execute a query on a subdocument and I didn't manage to make it work .....
My CosmosDB documents are like that:
```
{
[...]
"references": [
{
"id": "1234",
"link": "http://site.com/1234"
},
{
"id": "5678",
"link": "http://site.com/5678"
}
]
```
The query I tried is this one: `SELECT * FROM r WHERE ARRAY_CONTAINS(r.references, {id:'1234'}, true)`
( note that the third 'true' parameter to ARRAY_CONTAINS() is to say "the provided object is incomplete" )
With this request, I have this error:
```panic: BadRequest, Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception.```
Next I tried to use QueryDocument with Partition like that:
```
partitionKey := func(reqOpts *documentdb.RequestOptions) {
reqOpts.PartitionKey = []string{"/internal_id"}
}
query := fmt.Sprintf("SELECT * FROM r WHERE ARRAY_CONTAINS(r.references, {id:'1234'}, true)")
var ObjFound []Obj
err = client.QueryDocumentsWithRequestOptions(coll.Self, query, &ObjFound, partitionKey)
if err != nil {
panic(err)
}
```
With that, I don't have any error, but I am not finding any documents ...
Moreover, this request works fine in the Azure Data Explorer from the web interface.
Did someone manage to make that kind of request work ?
Thank you !
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
The issue is about querying subdocuments in CosmosDB using the Go driver. The user's query with ARRAY_CONTAINS fails with a cross-partition error or returns no results. Start by examining the QueryDocumentsWithRequestOptions method and how partition keys are handled. Check the driver's query execution logic and compare it with the working Azure Data Explorer query. Look for any discrepancies in query formatting or partition key specification.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- azure, go
- Domínio
- backend, databases
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 30/100