简体   繁体   中英

ElasticSearch document field size

I am trying to obtain metadata about the document types within an elasticsearch index. Any ideas on how I could retrieve the maximum length of a string field?

After enabling dynamic scripting the following did the trick for me (provided there where no nulls):

POST /myIndex/_search?Document' -d '
{
    "query" : {
        "filtered" : {
            "filter" : {
                "exists" : { "field" : "someField" }
            }
        }
    },    
    "aggs" : {
        "max_length" : { "max" : { "script" :doc['someField'].value.length()" } }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM