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

**URL:** <https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564>\
**Category:** Elasticsearch\
**Created:** [March 13, 2020, 6:51pm UTC](https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564 "2020-03-13T18:51:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [March 13, 2020, 6:51pm UTC](https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564/1 "2020-03-13T18:51:11Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [March 16, 2020, 1:27pm UTC](https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564/2 "2020-03-16T13:27:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [March 16, 2020, 7:09pm UTC](https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564/3 "2020-03-16T19:09:48Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 13, 2020, 7:09pm UTC](https://discuss.elastic.co/t/a-document-doesnt-have-a-value-for-a-vector-field/223564/4 "2020-04-13T19:09:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
