Terms query success on ID, fails on everything else

Doing the following search:

    curl --location --request POST 'localhost:9200/author/_search?pretty' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": {
    "terms": {
      "_id": [ "myName" ]
    }
  } 
}'

Return one hit, the following:

{
    "_index": "author",
    "_type": "_doc",
    "_id": "myName",
    "_score": 1.0,
    "_source": {
        // data //
        "name": "myName"
    }
}

Then the following request, calling this time for the name directly

    curl --location --request POST 'localhost:9200/author/_search?pretty' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": {
    "terms": {
      "name": [ "myName" ]
    }
  } 
}'

And no hit is returned. Is there something I'm missing ? Shouldn't the source content also be queryable ? Thank you for your help

What is the mapping for the name field? If you are using default mappings it is likely analyzed and therfore lowercased. You should try to instead use the name.keyword multi-field, which contains a keyword mapping of the field.

1 Like

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