Skip to content

Unflatten index options consistently (+tests)#120

Merged
toptobes merged 2 commits intomainfrom
SL-issue104-POST99-unflatten-index-options
Apr 8, 2026
Merged

Unflatten index options consistently (+tests)#120
toptobes merged 2 commits intomainfrom
SL-issue104-POST99-unflatten-index-options

Conversation

@sl-at-ibm
Copy link
Copy Markdown
Collaborator

fixes #104 .

This PR replaces the manual un/nesting of the table index "Options" to and from the payloads and responses, restoring isomorphism between the class encapsulation and the shape of the JSONs.

The builder methods are essentially unchanged (and they are flat), only the data structures are brought in line with the underlying Data API structure.
(so, if you use a builder, it should stay unchanged; conversely, if you create the index definition manually, your code will change somewhat).

Along the way, some attention is given to the tests.

Default/omitted entries should now not make it into the payload.

Two more items on the "text index":

  1. the polymorphism of the "Analyzer" attribute (a string; an enum value; a specific class; a free-form dictionary) require a new converter that piggybacks on the "DeepDictionaryConverter". A general rule here is to make life easier to the caller for not-performance-critical calls (e.g. list indexes), by eagerly converting everything into a dict; while for row reading (possibly a performance concern) a JsonElement would be acceptable.
  2. this polymorphism is such that you do not always read back what you sent. E.g. you send a string or a TextAnalyzer enum value, you'll read a string in both cases).

@sl-at-ibm
Copy link
Copy Markdown
Collaborator Author

@a-random-steve FYI

@sl-at-ibm sl-at-ibm requested a review from toptobes March 31, 2026 21:31
/// <param name="sourceModel">Allows enabling certain vector optimizations on the index by specifying the source model for your vectors</param>
/// <returns></returns>
public TableVectorIndexDefinition Vector(SimilarityMetric? metric, string sourceModel)
public TableVectorIndexDefinition Vector(SimilarityMetric? metric, string? sourceModel)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to support for .net 462, we've been trying not to use nullables on reference types in the actual API (except in tests). That is, I've been taking these warnings seriously and avoiding code that causes them.


[JsonPropertyName("analyzer")]
[JsonConverter(typeof(ObjectOrStringConverter))]
public object Analyzer { get; set; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of infamous 99 was clearing all these warning from existing code :)

@sl-at-ibm
Copy link
Copy Markdown
Collaborator Author

@a-random-steve Thanks for spotting those! I should have addressed both (and while I was at it I added another set of xml comments to bring the warnings to zero. I know it's out of scope for this PR but it's just comments (ahem)).

Checking the changes should be super quick (I am not so experienced with c# to trust myself with this, sorry).

@sl-at-ibm sl-at-ibm requested a review from a-random-steve April 2, 2026 21:13
@toptobes toptobes merged commit db45d2f into main Apr 8, 2026
2 checks passed
@toptobes toptobes deleted the SL-issue104-POST99-unflatten-index-options branch April 8, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not flatten the index 'Options', keep them as in payloads/responses

3 participants