Skip to content

Array into metadata of vector #79

Answered by neon-sunset
MUSS-Davs asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MUSS-Davs ,
This is a restriction due to how metadata operates in relation to C# being strongly typed. Because MetadataMap is a dictionary of string:MetadataValues, List<string> has to be converted to List<MetadataValue> which itself can be implicitly converted to MetadataValue node.

The way to deal with this is to map sequences / maps of your values to corresponding MetadataValues like this:

var idList = new List<string> { "id1", "id2", "id3" };

var metadata = new MetadataMap
{
    ["genre"] = "horror",
    ["duration"] = 120,
    ["idList"] = idList
        .Select(id => (MetadataValue)id)
        .ToArray()
};

var vector = new Vector
{
    Id = "vector1",
    Values = [0.1f, 0.2f, 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@neon-sunset
Comment options

Answer selected by MUSS-Davs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants