Can't get index to work

I am trying to add an index to my document. I can add the fields but the index is not built. I can update it in Word itself and it is working, but trying to call Update() on the TableOfEntriesClass leads to the following error:
System.NotSupportedException: 'TableOfEntries.Update() is currently supported only when TableOfEntries.FieldType is FieldType.TOC.'
Are other tables than TOC not supported yet? This would be a major problem for me since I was relying on that feature as it is mentioned in the TableOfEntries Class documentation: Represents a Table of Entries field, such as Table of Contents, Table of Figures, Table of Authorities, Index or Bibliography.
Or am I just missing something?
Here is my test code:

DocumentModel document = new DocumentModel();

Section section = new Section(document);
document.Sections.Add(section);

Paragraph paragraph = new Paragraph(document);
section.Blocks.Add(paragraph);
Run run = new Run(document, "Hello World!");
paragraph.Inlines.Add(run);
paragraph.Inlines.Add(new Field(document, FieldType.XE, $"\"Hello\""));

Paragraph paragraph2 = new Paragraph(document);
section.Blocks.Add(paragraph2);
Run run2 = new Run(document, "Hello World 2!");
paragraph2.Inlines.Add(run2);
paragraph2.Inlines.Add(new Field(document, FieldType.XE, $"\"Hello2\""));

var toe = new TableOfEntries(document, FieldType.Index);
section.Blocks.Add(toe);

// toe.Update(); // System.NotSupportedException: 'TableOfEntries.Update() is currently supported only when TableOfEntries.FieldType is FieldType.TOC.'

Hi,

Yes, I’m afraid that TableOfEntries.Update() currently supports updating only TOC element (please check the TableOfEntries.Update method’s description.

Nevertheless, can you send us an example of your document with an Index element?
I’ll create a sample code for you so that you can update it.

Regards,
Mario

Thanks for the fast response. I have build a solution for myself, which is not beautiful but works. Since an index is basically a table of contents with alphabetical sorting I came up with the following:

// basic setup and adding three entries
DocumentModel document = new DocumentModel();

Section section = new Section(document);
document.Sections.Add(section);

Paragraph paragraph = new Paragraph(document);
section.Blocks.Add(paragraph);
Run run = new Run(document, "Zoom run");
paragraph.Inlines.Add(run);
// important here is the `\f index` id for the entry which allows the toc to collect only entrances with this id
paragraph.Inlines.Add(new Field(document, FieldType.TC, $"\"Zoom index\" \\l \"1-1\" \\f index"));
paragraph.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.PageBreak));

Paragraph paragraph2 = new Paragraph(document);
section.Blocks.Add(paragraph2);
Run run2 = new Run(document, "Xeno run");
paragraph2.Inlines.Add(run2);
paragraph2.Inlines.Add(new Field(document, FieldType.TC, $"\"Xeno index\" \\l \"1-1\" \\f index"));
paragraph2.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.PageBreak));

Paragraph paragraph3 = new Paragraph(document);
section.Blocks.Add(paragraph3);
Run run3 = new Run(document, "Alphabet run");
paragraph3.Inlines.Add(run3);
paragraph3.Inlines.Add(new Field(document, FieldType.TC, $"\"Alphabet index\" \\l \"1-1\" \\f index"));
paragraph3.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.PageBreak));

// adding a table of content as usual
var toe = new TableOfEntries(document, FieldType.TOC);
// make it collect only index entries using \f
toe.InstructionText = "\\l \"1-1\" \\f index \\h";
section.Blocks.Add(toe);
// update everything to get the right page numbers
toe.Update();
document.GetPaginator(new PaginatorOptions() { UpdateFields = true });

// here it gets... interesting
// sort all entries alphabetically
var sorted = toe.Entries.OrderBy(entry => entry.Content.ToString());
// the toe.Entries is made up of paragraphs which can be cloned and readded
foreach (var entry in sorted)
{
    section.Blocks.Add(entry.Clone(true));
}

// remove the initial toe since we don't need it anymore
section.Blocks.Remove(toe);

This Index will remove the word field so you lose the option to update. I am using it for PDF generation, where this is not a problem.
You may have to add an Id to other tables of contents as well to avoid things getting mixed up, not sure about that.