title: How to add an item to a custom index in Sitecore programmatically?
body: <p>I have created my custom Index in Sitecore with <code>FlatDataCrawler</code>.
  Now I am going to add new item inherited from <code>AbstractIndexable</code> to my index.</p>
  
  <pre><code>private void Test() {
      var newItem = new ContactIndexable {
          Number = new System.Random().Next(500, 10000),
          MyField = "Item from IMPORTER"
      };
      var index = ContentSearchManager.GetIndex("my_index");
      using (var ctx = index.CreateUpdateContext()) {
          //This line doesn't work:
          ctx.Index.Operations.Add(newItem, index.CreateUpdateContext(), index.Configuration);
          index.Refresh(newItem);
      }
  
  }
  </code></pre>
  
  <p>Calling this code causes that only the <code>GetItemsToIndex</code> method is called in my custom crawler, but the element is not added to the Index.</p>
  
  <p>So, how can I add a new item to my custom index from code?</p>
  
  <p>This method works correctly and a new element is added to the index:</p>
  
  <pre><code>protected override IEnumerable&lt;ContactIndexable&gt; GetItemsToIndex() {
      List&lt;ContactIndexable&gt; items = new List&lt;ContactIndexable&gt;() {
          new ContactIndexable()
          {
               MyField = "Created in crawler"
          }
      };
      return items;
  }
  </code></pre>