Azure search index : Distict query requires a matching order by in order to return a continuation token
SreekanthOAuth opened this issue · 2 comments
We are trying to create the index from cosmosDb.
Our collection data format -
[
{
"parent_name": "XYX-YXY",
"parent_id": 123456,
"childName": "abcd"
"parent_image": "https://www.google.com/1.jpg",
"_rid": "ZBQxAL3VfK5vDwAAAAAAAA==",
"_ts": 1599155970
},
{
"parent_name": "XYX-YXY",
"parent_id": 123456,
"childName": "abcd"
"parent_image": "https://www.google.com/1.jpg",
"_rid": "ZBQxAL3VfK5vDwAAAAAAAA==",
"_ts": 1599155970
},
{
"parent_name": "EDC-YXY",
"parent_id": 123456,
"childName": "abcde"
"parent_image": "https://www.google.com/1.jpg",
"_rid": "ZBQxAL3VfK5vDwAAAAAAAA==",
"_ts": 1599155970
},
{
"parent_name": "EDC-YXY",
"parent_id": 123456,
"childName": "abcd"
"parent_image": "https://www.google.com/1.jpg",
"_rid": "ZBQxAL3VfK5vDwAAAAAAAA==",
"_ts": 1599155970
}
]
Our goal to get the Distict records by parent_id
Our Query : SELECT DISTINCT (c.parent_id), c.parent_name FROM c WHERE c._ts > @highwatermark
While trying to create the data source getting below exception
{ "error": { "code": "", "message": "Error with data source: Query is invalid. Error: 'Distict query requires a matching order by in order to return a continuation token.\r\nIf you would like to serve this query through continuation tokens, then please rewrite the query in the form 'SELECT DISTINCT VALUE c.blah FROM c ORDER BY c.blah' and please make sure that there is a range index on 'c.blah'.' Please adjust your data source definition in order to proceed." } }
And then we tried adding the order by but still facing the issue
Query : SELECT DISTINCT (c.parent_id), c.parent_name FROM c WHERE c._ts > @highwatermark ORDER BY c.parent_id
Need suggestions to create the azure search index in these situations.
Thanks,
Sreekanth - Ecolab
@SreekanthOAuth Sorry for the delay, just seeing this now. I'll try to repo the issue today.
@SreekanthOAuth Hello again -- it looks like you need help with setting up a cosmos db indexer. I can give you a few links to the docs (setting up the query is covered), but if you are still blocked after that, you should post to Stack Overflow.
https://docs.microsoft.com/en-us/azure/search/search-howto-index-cosmosdb
https://stackoverflow.com/questions/tagged/azure-cognitive-search
Since there are no problems with this sample specifically, I'm going to close this issue. Hope this helps!