title: Querying on Global Secondary indexes with a usage of contains operator
body: <p>I've been reading a DynamoDB docs and was unable to understand if it does make sense to query on Global Secondary Index with a usage of 'contains' operator.</p>
  <p>My problem is as follows: my dynamoDB document has a list of embedded objects, every object has a 'code' field which is unique:</p>
  <pre><code>    {
  
       &quot;entities&quot;:[
              {&quot;code&quot;:&quot;entity1Code&quot;, &quot;name&quot;:&quot;entity1Name&quot;}, 
              {&quot;code&quot;:&quot;entity2Code&quot;, &quot;name&quot;:&quot;entity2Name&quot;}
         ]
  
     }
  </code></pre>
  <p>I want to be able to get all documents that contain entities with <code>entity.code = X</code>.
  For this purpose I'm considering adding a Global Secondary Index that would contain all <code>entity.codes</code> that are present in current db document separated by a comma. So the example above would look like:</p>
  <pre><code>    {
  
       &quot;entities&quot;:[
              {&quot;code&quot;:&quot;entity1Code&quot;, &quot;name&quot;:&quot;entity1Name&quot;}, 
              {&quot;code&quot;:&quot;entity2Code&quot;, &quot;name&quot;:&quot;entity2Name&quot;}
         ],
       &quot;entitiesGlobalSecondaryIndex&quot;:&quot;entityCode1,entityCode2&quot;
     }
  </code></pre>
  <p>And then I would like to apply filter expression on <code>entitiesGlobalSecondaryIndex</code> something like: <code>entitiesGlobalSecondaryIndex contains entityCode1</code>.</p>
  <p>Would this be efficient or using global secondary index does not make sense in this way and DynamoDB will simply check the condition against every document which is similar so scan?</p>
  <p>Any help is very appreciated,</p>
  <p>Thanks</p>