2

I'm using Azure Table Storage on CosmosDB through Node.js. I figured out a hack using greater than and less than to give startsWith functionality.

On the other hand, I still need endsWith functionality and can't find a way to make it work. It might be one of those cases where I have to pull in all partition or row keys and then do the string search myself.

I noticed Azure Table has the same query format as odata and in this document for $filter, I'm seeing an endsWith command listed: https://learn.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)

Is there an endsWith command available or instead, is there a way to query all the partition or row keys and do the search myself?

Janley Zhang
  • 1,567
  • 7
  • 11
Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62

1 Answers1

3

Is there an endsWith command available or instead, is there a way to query all the partition or row keys and do the search myself?

Unfortunately both startsWith and endsWith commands are not available in Azure Table Storage. For startsWith, I am guessing you implemented a hack similar to the solution outlined here: Can PartitionKey be queried with StartsWith?.

However no such hack is available for endsWith. One possibility though will be to store another entity where you reverse the PartitionKey (or RowKey) and then apply startsWith hack. For example, your PartitionKey is abcdef and you need to find the entities that ends with ef, you could store another entity with PartitionKey as fedcba and then to apply the startsWith hack using fe (again reversing the string you're searching for).

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • I see what you're saying. Yeah, that's not something I'd want to manage. I will just query for the entire list of them. There won't be more than 100 or so anyway. Nothing too strenuous for JavaScript to handle. – Kevin Ghadyani Apr 08 '18 at 16:46
  • For 100 entities, yes the solution is an overkill. You could this filtering on the client side only. – Gaurav Mantri Apr 08 '18 at 16:48