title: RavenDB static index on dictionary
body: <p>I have an application that uses documents, that contain list of attributes in a dictionary, for some reason we need to use a static index and query/filter over these attributes.</p>
  
  <p>A prototype looks like this:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          IDocumentStore store = new DocumentStore() { DefaultDatabase = "Test", Url = "http://localhost:8081" };
          store.Initialize();
  
          IndexCreation.CreateIndexes(typeof(Program).Assembly, store);
  
          using (var session = store.OpenSession())
          {
              session.Store(new Document { Id = "1", Name = "doc_name", Attributes = new Dictionary&lt;string, object&gt; { { "Type", "1" }, { "Status", "Active" } } });
              session.SaveChanges();
          }
  
          using (var session = store.OpenSession())
          {
              // works
              var l1 = session.Query&lt;Document, Documents_Index&gt;().Where(a =&gt; a.Attributes["Type"] == "1").ToList();
              // not working
              var l2 = session.Query&lt;Document, Documents_Index&gt;().Where(a =&gt; a.Attributes["Status"] == "Active").ToList();
          }
      }
  }
  
  public class Documents_Index : AbstractIndexCreationTask&lt;Document&gt;
  {
      public Documents_Index()
      {
          Map = docs =&gt; docs.Select(a =&gt;
           new
           {
               a.Name,
               a.Attributes,
               Attributes_Type = a.Attributes["Type"]
           });
      }
  }
  
  [Serializable]
  public class Document
  {
      public string Id { get; set; }
      public string Name { get; set; }
      public Dictionary&lt;string, object&gt; Attributes { get; set; }
  }
  </code></pre>
  
  <p>But since I need to query using any arbitrary Attribute name/value this index does solve our problem. Actually the list of attributes is known at run-time (so we tried modifying the Map expression to inject any number of attribute names, but so far we weren't successful). Is there a way how to define the index in some dynamic fashion? </p>