Bhuvan
Bhuvan

Reputation: 1573

DocumentDB LinQ Request rate is large

I am trying to use DocumentDB, a small database and trying to do text search on one of the columns using LinQ in C#. When the query is executed, I am getting "request rate is too high" error message and data returning really slow.

Database is set at 400RU. I am still testing the database and I am doing a single request using LinQ.

Error Message:

Operation will be retried after 9707 milliseconds. Current attempt 1, Cumulative delay 00:00:09.7070000 Exception: Microsoft.Azure.Documents.DocumentClientException: Message: {"Errors":["Request rate is large"]}

Here is my Query:

var feed = from c in _client.CreateDocumentQuery<DataModel.Company>(_collUri, new FeedOptions() { MaxItemCount = 20 })
                            where c.Name.ToLower().Contains(keyword.ToLower())
                            select new { c.CIK, c.Name, Index = c.Name.ToLower().IndexOf(keyword.ToLower()) };

Document structure:

{      
  "Company Name": "ABC Test Company, Inc.",
  "Meta": [],
  "Aux": [
    {
      "file Type": "T",
      "Date posted": "2017-01-20",
      "Filename": "ccc/data/1695034/a.txt"
    }
  ],
  "id": "1695034"
}

*Company.Name is mapped to "Company Name" field in DocumentDB

Upvotes: 1

Views: 976

Answers (2)

Matias Quaranta
Matias Quaranta

Reputation: 15593

If you are going to do text searches, I'd recommend using Azure Search on top of DocumentDB.

You can index the information on DocumentDB with Indexers.

Azure Search would yield a better search experience in these cases (text searching) and it won't impact on your DocumentDB throughput. It has it's own service charge though so it should be taken into consideration. If you application will rely heavily on text search capabilities, it is probably the best choice.

For a more detailed service description, here are some articles that might help:

Upvotes: 0

Larry Maccherone
Larry Maccherone

Reputation: 9523

Any time you manipulate the data in a field before you do a comparison in the "WHERE" part of your query and there is no other more selective clause, you automatically trigger a full table scan (no indexes used). So, c.Name.ToLower() is just such a manipulation.

You could work around this issue by storing an additional field with the name already in lower case and using that field in your query.

Upvotes: 4

Related Questions