Home > Blockchain >  In Elasticsearch, how do you find out if an index's fields have doc_values set to true?
In Elasticsearch, how do you find out if an index's fields have doc_values set to true?

Time:06-07

When I run the following to get the mapping, it doesn't tell me which fields have doc_values set to true (or which fields have index set to true, for that matter). Is there a command or query to get that information?

GET sample/_mapping

Response:

    {
      "sample" : {
        "mappings" : {
          "dynamic" : "strict",
          "properties" : {
            "division" : {
              "type" : "keyword"
            },
            "losses" : {
              "type" : "integer"
            },
            "members" : {
              "type" : "nested",
              "properties" : {
                "age" : {
                  "type" : "integer"
                },
                "code" : {
                  "type" : "keyword"
                },
                "exp" : {
                  "type" : "float"
                },
                "height" : {
                  "type" : "integer"
                },
                "memberId" : {
                  "type" : "keyword"
                },
                "weight" : {
                  "type" : "integer"
                }
              }
            },
            "teamAge" : {
              "type" : "integer"
            },
            "teamId" : {
              "type" : "keyword"
            },
            "wins" : {
              "type" : "integer"
            }
          }
        }
      }
    }

CodePudding user response:

Tldr;

They are not shown because they ave the default value. By default doc_value and index are true

To test

PUT 72493929-3
{
  "mappings": {
    "properties": {
      "status_code": { 
        "type":  "long",
        "index": true,
        "doc_values": true
      },
      "session_id": { 
        "type":  "long",
        "index": false,
        "doc_values": false
      }
    }
  }
}

GET 72493929-3/_mapping

Which will give you :

{
  "72493929" : {
    "mappings" : {
      "properties" : {
        "session_id" : {
          "type" : "long",
          "index" : false,
          "doc_values" : false
        },
        "status_code" : {
          "type" : "long"
        }
      }
    }
  }
}
  • Related