Azure / azure-search-vector-samples

A repository of code samples for Vector search capabilities in Azure AI Search.
https://azure.microsoft.com/products/search
MIT License
731 stars 308 forks source link

The vector field 'Vector' must have the property 'dimensions' set #265

Open Elizabeth819 opened 3 weeks ago

Elizabeth819 commented 3 weeks ago

code: "name": "actionsVector", "type": "Collection(Edm.Single)", "searchable": True,
"retrievable": True, "dimensions": 3072, "vectorSearchProfile": "vector-profile",

service_name = "cobra-video-search-eliz" admin_key = "" api_version = "2024-07-01"

index_name = "complexscene_index"

Create a SearchIndexClient to manage the index

index_client = SearchIndexClient( endpoint=f"https://{service_name}.search.windows.net", credential=AzureKeyCredential(admin_key), api_version=api_version, )

Add IDs to documents

for i, doc in enumerate(data):

summary_vector = generate_embedding(doc['summary'])
documents.append({
        "@search.action": "mergeOrUpload",  #
        "id": str(i),
        "characters": doc.get("characters", ""),
        "summary": doc.get("summary", ""),
        "summaryVector": summary_vector,
        "chunk_id": f"chunk_{i}"
        })

Upload documents to the index

try: result = search_client.upload_documents(documents=documents)

error: Failed to create or update index: (InvalidRequestParameter) The request is invalid. Details: definition : The vector field 'summaryVector' must have the property 'dimensions' set. Code: InvalidRequestParameter Message: The request is invalid. Details: definition : The vector field 'summaryVector' must have the property 'dimensions' set. Exception Details: (InvalidField) The vector field 'summaryVector' must have the property 'dimensions' set. Parameters: definition Code: InvalidField Message: The vector field 'summaryVector' must have the property 'dimensions' set. Parameters: definition

HeidiSteen commented 2 weeks ago

Hi @Elizabeth819, it looks like you provided the field definition for "actionsVector", but not for "summaryVector". Or do you have have a field mapping somewhere?? (assuming indexer-based-indexing)....