No mapping found for [filedname] in order to sort on

Hi,I am a new learner of Elastisearch.I use this api

GET /logstash-kafka-2020.04.12/_mapping/

in Kibana to search my index mapping ,and it returns contain:

{
  "logstash-kafka-2020.04.12" : {
    "mappings" : {
      "dynamic_templates" : [
        {
          "message_field" : {
            "path_match" : "message",
            "match_mapping_type" : "string",
            "mapping" : {
              "norms" : false,
              "type" : "text"
            }
          }
        },
        {
          "string_fields" : {
            "match" : "*",
            "match_mapping_type" : "string",
            "mapping" : {
              "fields" : {
                "keyword" : {
                  "ignore_above" : 256,
                  "type" : "keyword"
                }
              },
              "norms" : false,
              "type" : "text"
            }
          }
        }
      ],
      "properties" : {
       
            "file_pdb" : {
              "type" : "text",
              "norms" : false,
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
         ...........       

I use this api to search docs:

GET logstash-kafka-2020.04.12/_search
{
  "query": {
    "match": {
      "file_pdb": "taskhost" 
    }
  },
   "sort": { "file_pdb.keyword": { "order": "desc" }},
  "aggs": {
    "file_pdbs": {
      "terms": {
        "field": "file_pdb.keyword" 
      }
    }
  }
}

but it returns with an error:

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "No mapping found for [file_pdb.keyword] in order to sort on",
        "index_uuid": "xsRz0xnUR4i-_9YMrtMZYg",
        "index": "logstash-kafka-2020.04.12"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "logstash-kafka-2020.04.12",
        "node": "nVaZskjSRU6_I_OMkHdsTg",
        "reason": {
          "type": "query_shard_exception",
          "reason": "No mapping found for [file_pdb.keyword] in order to sort on",
          "index_uuid": "xsRz0xnUR4i-_9YMrtMZYg",
          "index": "logstash-kafka-2020.04.12"
        }
      }
    ]
  },
  "status": 400
}

From the mapping information,I do put a multi filed of "file_pdb.keyword".Why can't I use sort to search it? Please help me, thank you!

I know the reason, because "file_pdb.keyword" is a property of "data" object. So I should use "data.file_pdb.keyword" for searching.

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