Token count field type

    Create a mapping with a token count field:

    copy

    Index three documents with text fields:

    1. { "sentence": "To be, or not to be: that is the question." }

    copy

    1. PUT testindex/_doc/3
    2. { "sentence": "Now is the winter of our discontent." }

    copy

    Search for sentences with fewer than 10 words:

    The response contains one matching sentence:

    1. {
    2. "took" : 8,
    3. "timed_out" : false,
    4. "_shards" : {
    5. "successful" : 1,
    6. "skipped" : 0,
    7. "failed" : 0
    8. },
    9. "hits" : {
    10. "total" : {
    11. "relation" : "eq"
    12. },
    13. "max_score" : 1.0,
    14. {
    15. "_index" : "testindex",
    16. "_type" : "_doc",
    17. "_id" : "3",
    18. "_score" : 1.0,
    19. "_source" : {
    20. "sentence" : "Now is the winter of our discontent."
    21. }
    22. }
    23. ]
    24. }

    Parameters

    The following table lists the parameters accepted by token count field types. The analyzer parameter is required; all other parameters are optional.