weaviate / typescript-client

Official Weaviate TypeScript Client
https://www.npmjs.com/package/weaviate-client
BSD 3-Clause "New" or "Revised" License
64 stars 23 forks source link

Unable to update inverted index in schema - Vector index config is missing from the class schema #181

Closed michael-pont closed 1 month ago

michael-pont commented 1 month ago

I am attempting to update the stopwords in the inverted index of a collection. I am using config update method and am receiving the following error. Using "weaviate-client": "^3.1.3" and image 1.25.7

Error:

Error: Vector index config is missing from the class schema.
    at Function.vectors (/node_modules/weaviate-client/dist/node/cjs/collections/config/classes.js:65:38)
    at Function.schema (node_modules/weaviate-client/dist/node/cjs/collections/config/classes.js:38:50)
    at node_modules/weaviate-client/dist/node/cjs/collections/config/index.js:106:51
    at Generator.next (<anonymous>)
    at fulfilled (node_modules/weaviate-client/dist/node/cjs/collections/config/index.js:15:26)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Code:

  const client = await connectToWeaviateClient()
  const collection = client.collections.get<Location>(CustomClassName.LOCATION)

  const updateBody: CollectionConfigUpdate = {
    description: CityLocationClass.description,
    invertedIndex: {
      stopwords: {
        preset: 'en',
        removals: ['as', 'at', 'be', 'by', 'in', 'is', 'it', 'no', 'to'],
      },
    },
    replication: CityLocationClass.replication,
    vectorizers: CityLocationClass.vectorizers,
  }
  await collection.config.update(updateBody)

This line is throwing the error. Essentially current.vectorConfig is undefined.

 current.vectorConfig = MergeWithExisting.vectors(current.vectorConfig, [updateVectorizers]);

 static vectors(current, update) {
    if (current === undefined) throw Error('Vector index config is missing from the class schema.');
    if (update === undefined) return current;

Value of current variable while debugging code. There is no vectorConfig defined in the object.

{
  class: "Location",
  description: "A class holding location information for matching unstructured location data",
  invertedIndexConfig: {
    bm25: {
      b: 0.75,
      k1: 1.2,
    },
    cleanupIntervalSeconds: 60,
    stopwords: {
      additions: null,
      preset: "en",
      removals: [
        "as",
        "at",
        "be",
        "by",
        "in",
        "is",
        "it",
        "no",
        "to",
      ],
    },
  },
  moduleConfig: {
    "text2vec-openai": {
      baseURL: "https://api.openai.com",
      dimensions: 1536,
      model: "text-embedding-3-small",
      tokenization: "word",
      type: "text",
      vectorizeClassName: false,
    },
  },
  multiTenancyConfig: {
    autoTenantActivation: false,
    autoTenantCreation: false,
    enabled: false,
  },
  properties: [
    {
      dataType: [
        "text",
      ],
      description: "The account id",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: true,
          vectorizePropertyName: false,
        },
      },
      name: "world_city_id",
      tokenization: "word",
    },
    {
      dataType: [
        "text",
      ],
      description: "The city of the location",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: false,
          vectorizePropertyName: false,
        },
      },
      name: "city",
      tokenization: "word",
    },
    {
      dataType: [
        "text",
      ],
      description: "The country of the location",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: false,
          vectorizePropertyName: false,
        },
      },
      name: "country",
      tokenization: "word",
    },
    {
      dataType: [
        "text",
      ],
      description: "The name of the highest level administration region of the city town (e.g. a US state or Canadian province). Based on the GENC profile of the ISO 3166-2 standard. Possibly blank.",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: false,
          vectorizePropertyName: false,
        },
      },
      name: "admin_name",
      tokenization: "word",
    },
    {
      dataType: [
        "text",
      ],
      description: "The ISO 2 country code of the location",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: true,
          vectorizePropertyName: false,
        },
      },
      name: "iso2_country_code",
      tokenization: "word",
    },
    {
      dataType: [
        "text",
      ],
      description: "The ISO 3 country code of the location",
      indexFilterable: true,
      indexSearchable: true,
      moduleConfig: {
        "text2vec-openai": {
          skip: true,
          vectorizePropertyName: false,
        },
      },
      name: "iso3_country_code",
      tokenization: "word",
    },
    {
      dataType: [
        "number",
      ],
      description: "Population of the location",
      indexFilterable: true,
      indexSearchable: false,
      moduleConfig: {
        "text2vec-openai": {
          skip: false,
          vectorizePropertyName: false,
        },
      },
      name: "population",
    },
  ],
  replicationConfig: {
    factor: 1,
  },
  shardingConfig: {
    actualCount: 1,
    actualVirtualCount: 128,
    desiredCount: 1,
    desiredVirtualCount: 128,
    function: "murmur3",
    key: "_id",
    strategy: "hash",
    virtualPerPhysical: 128,
  },
  vectorIndexConfig: {
    bq: {
      enabled: false,
    },
    cleanupIntervalSeconds: 300,
    distance: "cosine",
    dynamicEfFactor: 8,
    dynamicEfMax: 500,
    dynamicEfMin: 100,
    ef: -1,
    efConstruction: 128,
    flatSearchCutoff: 40000,
    maxConnections: 64,
    pq: {
      bitCompression: false,
      centroids: 256,
      enabled: false,
      encoder: {
        distribution: "log-normal",
        type: "kmeans",
      },
      segments: 0,
      trainingLimit: 100000,
    },
    skip: false,
    vectorCacheMaxObjects: 1000000000000,
  },
  vectorIndexType: "hnsw",
  vectorizer: "text2vec-openai",
}
tsmith023 commented 1 month ago

Hi @michael-pont, thanks for raising this! I can see where the error is and will push a fix now and release a new patch later with all the other bug-fixes that you've reported. Cheers!