# How to build a bulk request to post multiple values on a dense\_vector field

**URL:** <https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [April 24, 2024, 4:23pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147 "2024-04-24T16:23:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanqwam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivanqwam/32/28102_2.png) [@ivanqwam](https://discuss.elastic.co/u/ivanqwam)\
**Post date:** [April 24, 2024, 4:23pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147/1 "2024-04-24T16:23:20Z")

</div>

I have a document describing a **video** in which there are **multiple frames/images**.  
The use case is to find the video containing frames/images similar to a given image.  
An image embedding is computed on each Frame/image and stored in a dense\_vector field named **Frame\_vector**.  
To index this with a bulk request, I have to store **multiple values in a single dense\_vector field**

To do this, logically I should **post a JSONArray of JSONArray** / Jagged array / array of array to the dense\_vector field **Frame\_vector**.

Here is my **Bulk request** :

```auto
2024/04/24 16:46:32 347-qesjsp-null-DEBUG-QESHost_elastic81-bulkProcess()	: bulkJsonRequest::{"index":{"_index":"mediasearch","_id":"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця.xml"}}
"Frame":["uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_0.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_1.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_2.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_3.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_4.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_5.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_6.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_7.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_8.jpg",
"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця_Frame_9.jpg"],
"Frame_desc":["a woman in a black shirt and a white tank top",
"a man is looking at a computer screen",
"a man in a blue shirt is smiling",
"a man standing next to a man with a microphone",
"a man in a blue shirt holding a blue and white object",
"a man in a suit and tie standing in front of a microphone",
"a man standing next to a giant clock",
"a man holding a game controller in his hand",
"a man standing next to a large fish in a mirror",
"two men in military uniforms sitting on a couch"],
"Frame_vector":[
[-0.3481926918029785,-0.13305401802062988,.........,0.98209947645664215,-0.9743254542350769],
[-0.4481926918029785,-0.23305401802062988,.........,0.88209947645664215,-0.3743254542350769],
[-0.5481926918029785,-0.33305401802062988,.........,0.78209947645664215,-0.3743254542350769],
[-0.6481926918029785,-0.43305401802062988,.........,0.68209947645664215,-0.5743254542350769],
[-0.7481926918029785,-0.53305401802062988,.........,0.58209947645664215,-0.3743254542350769],
[-0.8481926918029785,-0.63305401802062988,.........,0.48209947645664215,-0.0743254542350769],
[-0.9481926918029785,-0.63305401802062988,.........,0.38209947645664215,-0.3743254542350769],
[-0.0481926918029785,-0.73305401802062988,.........,0.28209947645664215,-0.3743254542350769],
[-0.1481926918029785,-0.73305401802062988,.........,0.18209947645664215,-0.6743254542350769],
[-0.2481926918029785,-0.03305401802062988,.........,0.08209947645664215,-0.3743254542350769]
]
}

```

Here is what I get as a response:

```auto
2024/04/24 16:46:32 872-qesjsp-null-ERROR-ElasticApiService-parseBulkResponse()	: Erreur dans le Bulk:{"took":64,"items":[{"index":{"_index":"mediasearch","_id":"uk/Віталіи_Кім_про_виклики_у_перші_дні_вторгнення_Миколаівськии_Ваньок_та_мотивацію_Хоробрі_серця.xml","error":{"reason":"[1:11814] failed to parse: Failed to parse object: expecting token of type [VALUE_NUMBER] but found [START_ARRAY]","caused_by":{"reason":"Failed to parse object: expecting token of type [VALUE_NUMBER] but found [START_ARRAY]","col":11814,"line":1,"type":"parsing_exception"},"type":"document_parsing_exception"},"status":400}}],"errors":true}

```

Is this even possible ?  
Am I wrong with my assertion : **array of array**?

Thank you for your help

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 24, 2024, 5:28pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147/2 "2024-04-24T17:28:27Z")

</div>

You would need to use nested fields IMO. If supported as I never tested that.

What is the mapping?

Otherwise you should denormalize and index frames one by one instead. Which would probably have my preference.

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [April 24, 2024, 6:54pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147/3 "2024-04-24T18:54:54Z")

</div>

How do you plan on searching for it? Similarity searching for a particular frame in the video?

As @dadoonet mentioned, nested dense vector query would be a good candidate

[Docs](https://www.elastic.co/guide/en/elasticsearch/reference/8.13/query-dsl-knn-query.html#knn-query-with-nested-query)  
[Search Labs article with mappings for dense\_vector](https://www.elastic.co/search-labs/blog/chunking-via-ingest-pipelines#mappings-example)

Joe

---

<div class="post-metadata">

**Author:** ![ivanqwam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivanqwam/32/28102_2.png) [@ivanqwam](https://discuss.elastic.co/u/ivanqwam)\
**Post date:** [April 25, 2024, 12:44pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147/4 "2024-04-25T12:44:15Z")

</div>

A response from dadoonet the great : I feel very flattered 🙂 ....  
.. and it is fully accurate as ever.

**nested fields** seems the definitive solution.

Since it has been marked as evil for performances , I never looked into it, but here, I have no choice.

With that in mind, I did a new research and found this previous issue:

([How to search Multiple dense vector fields, including nested filelds](https://discuss.elastic.co/t/how-to-search-multiple-dense-vector-fields-including-nested-filelds/326119))

Everything is in it. mine is a poor duplicate.

Thank you, you both, for your valuable help.

Please close.

---

<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:** [May 23, 2024, 12:44pm UTC](https://discuss.elastic.co/t/how-to-build-a-bulk-request-to-post-multiple-values-on-a-dense-vector-field/358147/5 "2024-05-23T12:44:33Z")

</div>

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