title: Error: The order by query does not have a corresponding composite index that it can be served from
body: <p>When executing the following query I receive an error</p>
  
  <p><code>select * from c order by c.Agent.LastStateChangeUnixTime desc,c.Priority asc</code></p>
  
  <blockquote>
    <p>The order by query does not have a corresponding composite index that it can be served from</p>
  </blockquote>
  
  <p>I have added a composite index as stated in the documentation <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/index-policy#modifying-the-indexing-policy" rel="nofollow noreferrer">here</a> and <a href="https://cosmosdb.github.io/labs/dotnet/labs/04-indexing_in_cosmosdb.html" rel="nofollow noreferrer">here</a></p>
  
  <p>Is my composite index wrong? Or am I missing something else?</p>
  
  <p>My index settings are:</p>
  
  <pre><code>{
      "indexingMode": "consistent",
      "automatic": true,
      "includedPaths": [
          {
              "path": "/*"
          }
      ],
      "excludedPaths": [
          {
              "path": "/\"_etag\"/?"
          }
      ],
      "compositeIndexes": [
          [
              {
                  "path": "/Priority",
                  "order": "descending"
              },
              {
                  "path": "/Agent/LastStateChangeUnixTime",
                  "order": "ascending"
              }
          ]
      ]
  }
  </code></pre>
  
  <p>Example Object:</p>
  
  <pre><code>{
      "Agent": {
          "TenantId": 999999,
          "PrimaryState": "Null",
          "PendingState": "Null",
          "LastStateChange": "2020-01-18T05:48:11.5397269+00:00",
          "LastStateChangeUnixTime": 1579326491,
          "Notes": null,
          "AgentId": 123,
          "id": "agent-123"
      },
      "AgentId": 123,
      "SkillName": "English",
      "id": "SkillName123",
      "Priority": 10,
      "_rid": "SVIMANKqJboCAAAAAAAAAA==",
      "_self": "dbs/SVIMAA==/colls/SVIMANKqJbo=/docs/SVIMANKqJboCAAAAAAAAAA==/",
      "_etag": "\"2200819a-0000-0700-0000-5e229c1d0000\"",
      "_attachments": "attachments/",
      "_ts": 1579326493
  }
  </code></pre>