Skip to content

Display error for text_expansion if the queried field does not have the right type #98098

@ioanatia

Description

@ioanatia

Description

When text_expansion receives a field that does not have the rank_features type, it simply returns an empty list of results:

GET search-books/_search
{
   "query":{
      "text_expansion":{
         "wrong_inexistent_field":{
            "model_id":".elser_model_1",
            "model_text":"What wild animals live in Colorado?"
         }
      }
   }
}

response:

{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  }
}

The text_expansion docs clearly state that the queried field must be of rank_features type, but this is not enforced at the API level.

Other Elasticsearch queries return an error message when the queried field is missing or it does not have a compatible type.

With rank_features fields and the ELSER pipeline that users can create in Kibana in the Enterprise Search plugin, it is very easy to miss exactly what field needs to be queried, because the rank_features fields are deeply nested under ml.inference. For example, this is a working query:

GET search-books/_search
{
   "query":{
      "text_expansion":{
         "ml.inference.description_expanded.predicted_value":{
            "model_id":".elser_model_1",
            "model_text":"What wild animals live in Colorado?"
         }
      }
   }
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions