a8m / a8m/documentdb

Query sub array

オープン
#12 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
31
フォーク
26
PR マージ指標
30日以内にマージされた PR はありません

説明

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 !

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。