#community-help

Resolving Hybrid Query Error with 'vector_query'

TLDR Manish had an error with a hybrid query. Jason suggests using the field name embedding instead of vec and explains the weightage in hybrid searches.

Powered by Struct AI

2

15
1mo
Solved
Join the chat
Aug 30, 2023 (1 month ago)
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:37 PM
Hey folks. I'm getting this error when trying to do a hybrid query, with vector_query

{"results":[{"code":400,"error":"Field `vec` does not have a vector query index."}]}%                                                                  
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:42 PM
Could you share your schema?
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:42 PM
    threadsCol := `{"name": "threads", "fields": [
    {"name": ".*", "type": "auto"},
    {"name": "embedding",
     "type": "float[]",
     "num_dim": 384
    }
    ]}`
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:42 PM
Since the field is called embedding, you want to use that name instead of vec in your vector query
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:44 PM
And when giving this embedding, do I also need to specify k:100 , if I want hybrid search? "embedding:([%s], k:100)"
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:45 PM
Yeah
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:46 PM
If both q and vector_query are present, would it automatically do a hybrid search?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:46 PM
That's right
03:47
Jason
03:47 PM
Could you upgrade to 0.25.1.rc5 though - fixed some issues related to this in recent builds

1

Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:47 PM
    query["query_by"] = "subject,summary,chats,embedding"

So, this order is roughly correct? The "subject, summary, and chats" fields would constitute 70% towards the rank, and embedding would constitute 30%?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:48 PM
The 70 / 30 split in weightage is fixed at the moment, regardless of the position of the embedding field in query_by
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:48 PM
ok. works for me
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:48 PM
So 70% weightage on keyword search and 30% weightage on semantic search

1

Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
03:52 PM
btw, what level of precision in floats, does TS need? How many decimal points?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:00 PM
Typesense doesn't enforce any minimum precisions - that's completely dependent on the model