title: How to search on Cosmos DB in a complex JSON Object
body: <p>I have the following JSON Object, as you can see it references a TAG object, which is an array of tags.</p>
  
  <pre><code>public class GlobalPageTemplate : ISharedCosmosEntity
  {
      [JsonProperty("Id")]
      public string Id { get; set; }
  
      [CosmosPartitionKey]
      public string CosmosEntityName { get; set; }
  
      public string Description { get; set; }
      public string ExtractedPageName { get; set; }
      public string ExtractedSitecollectionTemplateName { get; set; }
      public string ExtractedGlobalDesignTenantId { get; set; }
      public string ExtractedGlobalDesigntenantSiteCollectionUrl { get; set; }
      public string PageTemplatePictureUrl { get; set; }
      public string Base64Image { get; set; }
      public string PageTemplateName { get; set; }
      public List&lt;Section&gt; Sections { get; set; }
      public string TemplateAccessLevel { get; set; }
      public List&lt;Tag&gt; Tags { get; set; }
  }
  
  public class Tag : ISharedCosmosEntity
  {
  
      [JsonProperty("Id")]
      public string Id { get; set; }
  
      public string TagName { get; set; }
  
      [CosmosPartitionKey]
      public string CosmosEntityName { get; set; }
  }
  </code></pre>
  
  <p>In the database, objects are saved like this:</p>
  
  <pre><code>{
      "CosmosEntityName": "globalpagetemplates",
      "Description": "depper",
      "ExtractedPageName": "Home.aspx",
      "ExtractedSitecollectionTemplateName": "CommunicationSite",
      "ExtractedGlobalDesignTenantId": "696da7e7-a03e-4996-bbf8-625b8e4c4c06",
      "ExtractedGlobalDesigntenantSiteCollectionUrl": "https://xx.sharepoint.com/sites/TST1",
      "PageTemplatePictureUrl": "https://xx.blob.core.windows.net/globalpagetemplatespictures/0befc979-3958-4e27-a345-f4ce491eb1ee.png",
      "Base64Image": "",
      "PageTemplateName": "Plantilla 5 TST 1",
      "Sections": [],
      "TemplateAccessLevel": "Platinum",
      "Tags": [
          {
              "Id": null,
              "TagName": "recursos humanos",
              "CosmosEntityName": null
          }
      ],
      "id": "0befc979-3958-4e27-a345-f4ce491eb1ee",
      "_rid": "q6JzALvx8ZHMCQAAAAAAAA==",
      "_self": "dbs/q6JzAA==/colls/q6JzALvx8ZE=/docs/q6JzALvx8ZHMCQAAAAAAAA==/",
      "_etag": "\"35001a26-0000-0300-0000-5df77cf60000\"",
      "_attachments": "attachments/",
      "_ts": 1576500470
  }
  </code></pre>
  
  <p>I have a method that returns ALL page templates:</p>
  
  <pre><code>/// &lt;returns&gt;&lt;/returns&gt;
  [HttpGet]
  public async Task&lt;IHttpActionResult&gt; GetGlobalPageTemplates()
  { 
      var telemetry = new TelemetryClient();
      try
      {
          var globalPageTemplateStore = CosmosStoreHolder.Instance.CosmosStoreGlobalPageTemplate;
          var globalPageTemplates =  await globalPageTemplateStore.Query().ToListAsync();
          return Ok(globalPageTemplates);
      }
      catch (Exception ex)
      {
          string guid = Guid.NewGuid().ToString();
          var dt = new Dictionary&lt;string, string&gt;
          {
              { "Error Lulo: ", guid }
          };
  
          telemetry.TrackException(ex, dt);
          return BadRequest("Error Lulo: " + guid);
      }
  }
  </code></pre>
  
  <p>However in the front end I can filter on TAGS, </p>
  
  <p>So I need to create a method that receives a list of strings and then makes the query to get the page templates that matches the TAGS,  the filter should be exclusive, I mean OR.</p>
  
  <pre><code>/// &lt;returns&gt;&lt;/returns&gt;
  [HttpGet]
  public async Task&lt;IHttpActionResult&gt; GetGlobalPageTemplatesByTags(List&lt;string&gt; tags)
  { 
      var telemetry = new TelemetryClient();
      try
      {
          var globalPageTemplateStore = CosmosStoreHolder.Instance.CosmosStoreGlobalPageTemplate;
          var globalPageTemplates =  await globalPageTemplateStore.Query().Where???
      }
      catch (Exception ex)
      {
          string guid = Guid.NewGuid().ToString();
          var dt = new Dictionary&lt;string, string&gt;
          {
              { "Error Lulo: ", guid }
          };
  
          telemetry.TrackException(ex, dt);
          return BadRequest("Error Lulo: " + guid);
      }
  }
  </code></pre>
  
  <p>any idea how to achieve this?</p>