Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Getting sparse vector value returns byte encrypted array #791

Open
1 task done
juanandreas opened this issue Jul 22, 2024 · 1 comment
Open
1 task done

Comments

@juanandreas
Copy link

juanandreas commented Jul 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I run this code to get the content of a sparse float vector:

searchResult.Fields.GetColumn("sparse_vector_column").FieldData().GetVectors().GetSparseFloatVector().GetContents()

I get:

["GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAADXo1A/","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAADXo1A/","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAABcj0I/","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAAAMAis/","QwEAAAAAgD9EAQAAAACAP2gBAAAAAIA/YAIAAAAAgD97AgAAAACAP4cCAAAAAIA/iQIAAAAAgD8hAwAAAACAPyIDAAAAAIA/IwMAAB1aJD8=","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAADjpRs/","QwEAAAAAgD9EAQAAAACAP2sBAAAAAIA/YAIAAAAAgD97AgAAAACAP4cCAAAAAIA/iQIAAAAAgD8hAwAAAACAPyIDAAAAAIA/IwMAAB+FGz8=","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD9rAQAAAACAP2ACAAAAAIA/ewIAAAAAgD+HAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAACamTk/","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD9rAQAAAACAP2ACAAAAAIA/ewIAAAAAgD+HAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAAAMAis/","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD+IAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAADRIts+","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD9JAQAAAACAP2sBAAAAAIA/bQEAAAAAgD91AQAAAACAP10CAAAAAIA/YAIAAAAAgD93AgAAAACAP3sCAAAAAIA/hgIAAAAAgD+HAgAAAACAP4kCAAAAAIA/IQMAAAAAgD8iAwAAAACAPyMDAAArhxY/","QwEAAAAAgD9EAQAAAACAP2sBAAAAAIA/YAIAAAAAgD97AgAAAACAP4cCAAAAAIA/iQIAAAAAgD8hAwAAAACAPyIDAAAAAIA/IwMAAC/dpD4=","GwEAAAAAgD82AQAAAACAP0IBAAAAAIA/RAEAAAAAgD9ZAQAAAACAP2sBAAAAAIA/YAIAAAAAgD97AgAAAACAP4cCAAAAAIA/iQIAAAAAgD8hAwAAAACAPyIDAAAAAIA/IwMAAD0Klz4="]

Expected Behavior

This should return me a hashmap of an integer to float32 value mapping.

Steps To Reproduce

No response

Environment

No response

Anything else?

No response

@aoiasd
Copy link
Contributor

aoiasd commented Jul 25, 2024

FieldData() used to get result proto data,so you will get the source data like []byte

Usually we could get colum data like
hits.Fields.GetColumn("pk").GetAsInt64(id)
but now we seems lack GetAsSparseVector.

Maybe you can get sparse data by

vector, err := hits.Fields.GetColumn("vector").Get(id)
if err != nil {
	return err
}
sparse,ok:= vector.(entity.SparseEmbedding)

or

vectorColumn := hits.Fields.GetColumn("vector").(*entity.ColumnSparseFloatVector)
sparse, err := vectorColumn.ValueByIdx(idx)
if err != nil {
	return err
}

But now SparseEmbedding only support get position and value by index, not return a map.

Seems we should complete GetSparseVector for Column and add Mapping method for SparseEmbedding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants