# Getting "Failed to index document for reason failed to parse field rank\_feature .elser\_model\_1

**URL:** <https://discuss.elastic.co/t/getting-failed-to-index-document-for-reason-failed-to-parse-field-rank-feature-elser-model-1/359662>\
**Category:** Elasticsearch\
**Created:** [May 16, 2024, 7:11pm UTC](https://discuss.elastic.co/t/getting-failed-to-index-document-for-reason-failed-to-parse-field-rank-feature-elser-model-1/359662 "2024-05-16T19:11:19Z")\
**Posts on this page:** 3\
**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:** [May 16, 2024, 7:11pm UTC](https://discuss.elastic.co/t/getting-failed-to-index-document-for-reason-failed-to-parse-field-rank-feature-elser-model-1/359662/1 "2024-05-16T19:11:19Z")

</div>

I have mappings and processors in line with other examples here. However, during the index generation, I get an error like:

```auto
{"date":"2024-05-16 14:53:43,147", "type":"ERROR", "class":"com.ibm.dp.datastore.utilities.ESUtils$2", "thread": "elasticsearch-rest-client-0-thread-2",
 "message": "Failed to index document due to this error: ErrorCause: {"type":"document_parsing_exception","reason":"[1:785] failed to parse field [path_expansion.tokens] of type [rank_feature] in document with id '0DF15005E4038DEEBDF13B1774B01E18B9894D2C_001'. 
Preview of field's value: 
'{cluster=0.15190549, string=2.8398185, data=0.53949, software=0.003122813, section=0.17318511, interface=0.38456964, inventory=0.34014818, malaysia=0.021001812, directory=0.16043624, platform=0.31209457, network=0.36547637, button=0.2672434, split=0.2064711, java=0.025861437, strings=1.767182, web=0.030292396, api=1.0258077, portal=1.5379529, website=0.18131517, sap=2.3315399, portals=0.24848863, module=0.18718521, tree=0.21967274, thread=0.5139853, list=0.12154329, message=0.06096609, m=0.10591241, script=0.06531332, help=1.3187134, component=0.08407042, field=0.16718304, serial=0.21964681, information=1.394739E-5, category=0.09415125, support=0.78008264, ~=0.34376627, status=0.16336815, customer=0.06774526}'",
"caused_by":{"type":"x_content_parse_exception",
"reason":"[1:30] Current token (START_OBJECT) not numeric, can not use numeric value accessors\n at [Source: ...

```

The "object" referenced appears to be a set of keyword=value pairs, not a proper JSON object (e.g., `{cluster=0.15190549, string=2.8398185, ...`), but this is generated from the text field I've passed in.

Examples of mapping and processors:

```auto
{
      "_source": {
        "enabled": "true"
      },
  "dynamic": "false",
  "properties": {
    "url": {
      "type": "text"
    },
    "title": {
      "type": "text",
      "analyzer": "text_keep_stopwords",
      "search_analyzer": "text_drop_stopwords",
      "term_vector": "with_positions_offsets",
      "index_options": "offsets",
      "store": "true"
    },
    "path": {
      "type": "text",
      "term_vector": "with_positions_offsets",
      "analyzer": "text_keep_stopwords",
      "search_analyzer": "text_drop_stopwords",
      "index_options": "offsets",
      "store": "true"
    },
    "path_expansion.tokens": {
      "type": "rank_feature"
    }
  }
}

```

processors:

```auto
	"processors": [
		{
			"inference": {
				"model_id": ".elser_model_1",
				"target_field": "path_expansion",
				"field_map": {
					"path": "text_field"
				},
				"inference_config": {
					"text_expansion": {
						"results_field": "tokens"
					}
				}
			}
		}
	]
}

```

The path variable is a string with words delimited by " ~ " like:  
"title ~ heading1 ~ heading2"

---

<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:** [May 17, 2024, 1:07pm UTC](https://discuss.elastic.co/t/getting-failed-to-index-document-for-reason-failed-to-parse-field-rank-feature-elser-model-1/359662/2 "2024-05-17T13:07:50Z")

</div>

The type in the mappings was missing an "s" -- needed to be "rank\_features"

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [May 17, 2024, 7:11pm UTC](https://discuss.elastic.co/t/getting-failed-to-index-document-for-reason-failed-to-parse-field-rank-feature-elser-model-1/359662/3 "2024-05-17T19:11:48Z")

</div>

Glad you figured it out @wnmills3 !

If you're in Elasticsearch 8.11+, we recommend that you use [sparse\_vector](https://www.elastic.co/guide/en/elasticsearch/reference/current/sparse-vector.html) field type for using ELSER. `rank_features` can be used as well, but `sparse_vector` will receive several upgrades in the near future.
