multi-termvectors.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. [[docs-multi-termvectors]]
  2. === Multi term vectors API
  3. ++++
  4. <titleabbrev>Multi term vectors</titleabbrev>
  5. ++++
  6. Retrieves multiple term vectors with a single request.
  7. [source,console]
  8. --------------------------------------------------
  9. POST /_mtermvectors
  10. {
  11. "docs": [
  12. {
  13. "_index": "twitter",
  14. "_id": "2",
  15. "term_statistics": true
  16. },
  17. {
  18. "_index": "twitter",
  19. "_id": "1",
  20. "fields": [
  21. "message"
  22. ]
  23. }
  24. ]
  25. }
  26. --------------------------------------------------
  27. // TEST[setup:twitter]
  28. [[docs-multi-termvectors-api-request]]
  29. ==== {api-request-title}
  30. `POST /_mtermvectors`
  31. `POST /<index>/_mtermvectors`
  32. [[docs-multi-termvectors-api-desc]]
  33. ==== {api-description-title}
  34. You can specify existing documents by index and ID or
  35. provide artificial documents in the body of the request.
  36. The index can be specified the body of the request or in the request URI.
  37. The response contains a `docs` array with all the fetched termvectors.
  38. Each element has the structure provided by the <<docs-termvectors,termvectors>>
  39. API.
  40. See the <<docs-termvectors,termvectors>> API for more information about the information
  41. that can be included in the response.
  42. [[docs-multi-termvectors-api-path-params]]
  43. ==== {api-path-parms-title}
  44. `<index>`::
  45. (Optional, string) Name of the index that contains the documents.
  46. [[docs-multi-termvectors-api-query-params]]
  47. ==== {api-query-parms-title}
  48. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fields]
  49. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=field_statistics]
  50. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=offsets]
  51. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=payloads]
  52. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=positions]
  53. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=preference]
  54. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=routing]
  55. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=realtime]
  56. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=term_statistics]
  57. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=version]
  58. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=version_type]
  59. [float]
  60. [[docs-multi-termvectors-api-example]]
  61. ==== {api-examples-title}
  62. If you specify an index in the request URI, the index does not need to be specified for each documents
  63. in the request body:
  64. [source,console]
  65. --------------------------------------------------
  66. POST /twitter/_mtermvectors
  67. {
  68. "docs": [
  69. {
  70. "_id": "2",
  71. "fields": [
  72. "message"
  73. ],
  74. "term_statistics": true
  75. },
  76. {
  77. "_id": "1"
  78. }
  79. ]
  80. }
  81. --------------------------------------------------
  82. // TEST[setup:twitter]
  83. If all requested documents are in same index and the parameters are the same, you can use the
  84. following simplified syntax:
  85. [source,console]
  86. --------------------------------------------------
  87. POST /twitter/_mtermvectors
  88. {
  89. "ids" : ["1", "2"],
  90. "parameters": {
  91. "fields": [
  92. "message"
  93. ],
  94. "term_statistics": true
  95. }
  96. }
  97. --------------------------------------------------
  98. // TEST[setup:twitter]
  99. [[docs-multi-termvectors-artificial-doc]]
  100. ===== Artificial documents
  101. You can also use `mtermvectors` to generate term vectors for _artificial_ documents provided
  102. in the body of the request. The mapping used is determined by the specified `_index`.
  103. [source,console]
  104. --------------------------------------------------
  105. POST /_mtermvectors
  106. {
  107. "docs": [
  108. {
  109. "_index": "twitter",
  110. "doc" : {
  111. "user" : "John Doe",
  112. "message" : "twitter test test test"
  113. }
  114. },
  115. {
  116. "_index": "twitter",
  117. "doc" : {
  118. "user" : "Jane Doe",
  119. "message" : "Another twitter test ..."
  120. }
  121. }
  122. ]
  123. }
  124. --------------------------------------------------
  125. // TEST[setup:twitter]