How to calculate the total document length


(atef bouabid) #1

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


(David Pilato) #2

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


(atef bouabid) #3

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
}

(David Pilato) #4

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


(Paul) #5

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.


(David Pilato) #6

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


(atef bouabid) #7

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


(system) #8

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