# Type "dense\_vector" not set on properties

**URL:** <https://discuss.elastic.co/t/type-dense-vector-not-set-on-properties/357211>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning, vector-search\
**Created:** [April 11, 2024, 1:21pm UTC](https://discuss.elastic.co/t/type-dense-vector-not-set-on-properties/357211 "2024-04-11T13:21:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wnmills3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wnmills3/32/133048_2.png) [@wnmills3](https://discuss.elastic.co/u/wnmills3)\
**Post date:** [April 11, 2024, 1:21pm UTC](https://discuss.elastic.co/t/type-dense-vector-not-set-on-properties/357211/1 "2024-04-11T13:21:37Z")

</div>

I've tried defining a passage\_embedding using both:

```auto
			"passage_embedding": {
				"type": "dense_vector",
				"dims": 768,
				"similarity": "cosine",
				"index": "true"
			},

```

and as follows:

```auto
			"passage_embedding.predicted_value": {
				"type": "dense_vector",
				"dims": 768,
				"similarity": "cosine",
				"index": "true"
			},

```

and I've also tried using a pipeline processor as:

```auto
		{
			"inference": {
				"model_id": "intfloat__multilingual-e5-base",
				"target_field": "passage_embedding",
				"field_map": {
					"passage": "text_field"
				}
			}
		},

```

as well as with an inference\_config:

```auto
    {
      "inference": {
        "model_id": "intfloat__multilingual-e5-base",
        "target_field": "passage_embedding",
        "field_map": {
          "passage": "text_field"
        },
        "inference_config": {
          "text_embedding": {
            "results_field": "predicted_value"
          }
        }
      }
    },

```

however, while I do receive an array of floats under the passage\_embedding.predicted\_values field the definition does not show as dense\_vector so attempting knn queries fails. What I get is:

```auto
              "passage_embedding": {
                "properties": {
                  "dims": {
                    "type": "long"
                  },
                  "index": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "similarity": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "type": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  }
                }
              },

```

Note, the size isn't getting set to 512 either.

---

<div class="post-metadata">

**Author:** ![wnmills3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wnmills3/32/133048_2.png) [@wnmills3](https://discuss.elastic.co/u/wnmills3)\
**Post date:** [April 12, 2024, 5:27pm UTC](https://discuss.elastic.co/t/type-dense-vector-not-set-on-properties/357211/2 "2024-04-12T17:27:28Z")

</div>

It turns out I was not performing the sequence of setting my mappings and settings correctly. I've moved to doing everything at once when creating the index rather than calling them separately. This code seems to fix the issues with the weird mappings I was getting:

```auto
        if (!indexExists(client, indexName)) {
            try {
                IndexSettings is = getSettingsRequest(indexName, langFamily);
                TypeMapping mr = getMappingsRequest(indexName, langFamily);
                client.indices()
                    .create(cir -> cir.timeout(Time.of(t -> t.time("60s")))
                        .index(indexName)
                        .settings(is)
                        .mappings(mr));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

        }

```

Before consolidating these actions, I'd created the index then sought to create the mappings by issuing a mapping request, and then I was trying to set the settings (but the mappings referenced analytics in the settings, and the empty mapping was already created when the index was created, so all kinds of problems...
