How to calculate the total document length

please is there anyone know how to calculate the total document length (number of characters)

You need to compute that at index time.
The mapper size plugin might help.

are you know why when i try to enable _size field

PUT category
{
  "mappings": {
    "cat": {
      "_size": {
        "enabled": true
      }
    }
  }
}

i got this error

{
  "error": {
    "root_cause": [
      {
        "type": "resource_already_exists_exception",
        "reason": "index [category/oDbxbu8nR42ieKtKSRZdZQ] already exists",
        "index_uuid": "oDbxbu8nR42ieKtKSRZdZQ",
        "index": "category"
      }
    ],
    "type": "resource_already_exists_exception",
    "reason": "index [category/oDbxbu8nR42ieKtKSRZdZQ] already exists",
    "`index_uuid`": "oDbxbu8nR42ieKtKSRZdZQ",
    "index": "category"
  },
  "status": 400
}

I believe you need to create a new index and reindex.

Do you is it possible to display the _size ? The docs say that it can be used for querying, aggregating, sorting etc but I can't find any way to access it in a view.

Try this: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-docvalue-fields.html

but me i looking to compute matching words to define a new score for a query (number(match_word)/number(document_word))

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