A document doesn't have a value for a vector field

Hi all,

Not all of my documents have a value for a vector field, and I seem to get this error when trying to use dotProductSparse on such documents:

A document doesn't have a value for a vector field

It seems that testing doc['sparse_vec_field_name'] == null is insufficient for detecting these cases.

What is the correct way to test for these cases?

Thanks!

The check should be doc['sparse_vec_field_name'].size() == 0.

1 Like

Thanks!