Skip to content

[Feature Request] Upserting a list of strings, numbers as metadata #195

@miljanbojanic

Description

@miljanbojanic

I need to be able to upsert a Lists of string and Numbers as metadata into the pinecone database (using embedded vector).
Here we have a method to insert just Map<String, String> type.(List<Map<String, String>> upsertRecords)

I tried to use some classes under the hood, like VectorOperationsApi class

It's working fine with number, I can insert them.. but I can not insert a list of strings.

code in Scala:
val apiKey = "apiKey"
val index = "someIndex"
val host = s"$index-otzyz6h.svc.gcp-europe-west4-de1d.pinecone.io"

val config     = new PineconeConfig(apiKey)
config.setHost(host)
val connection = new PineconeConnection(config)

val apiClient = new ApiClient()
apiClient.setApiKey(apiKey)

val vecApi = new VectorOperationsApi(apiClient)
vecApi.setCustomBaseUrl(s"https://$host")

val tags: util.List[String] = util.Arrays.asList("DDD", "EEE")
val rec = new UpsertRecord()
  .id("test1")
  .putAdditionalProperty("chunk_text", "Apples are a great source of dietary fiber…")
  .putAdditionalProperty("header2lead", "test header")
  .putAdditionalProperty("tags", tags)

vecApi.upsertRecordsNamespace("article_prelude", util.Arrays.asList(rec))

Error log:

Exception in thread "main" java.lang.IllegalStateException: Not a JSON Object: ["DDD","EEE"]
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:101)
at org.openapitools.db_data.client.model.UpsertRecord$CustomTypeAdapterFactory$1.write(UpsertRecord.java:233)
at org.openapitools.db_data.client.model.UpsertRecord$CustomTypeAdapterFactory$1.write(UpsertRecord.java:216)
at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:196)
at com.google.gson.Gson.toJson(Gson.java:842)
at com.google.gson.Gson.toJson(Gson.java:812)
at com.google.gson.Gson.toJson(Gson.java:759)
at com.google.gson.Gson.toJson(Gson.java:736)
at org.openapitools.db_data.client.JSON.serialize(JSON.java:166)

According to this documentation we should be able to insert list of strings.

Values must be one of the following data types:

  • String
  • Integer (converted to a 64-bit floating point by Pinecone)
  • Floating point
  • Boolean (true, false)
  • List of strings

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions