text-expansion-query.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. [[query-dsl-text-expansion-query]]
  2. == Text expansion query
  3. ++++
  4. <titleabbrev>Text expansion</titleabbrev>
  5. ++++
  6. The text expansion query uses a {nlp} model to convert the query text into a
  7. list of token-weight pairs which are then used in a query against a
  8. <<rank-features,rank features field>>.
  9. [discrete]
  10. [[text-expansion-query-ex-request]]
  11. === Example request
  12. [source,console]
  13. ----
  14. GET _search
  15. {
  16. "query":{
  17. "text_expansion":{
  18. "<rank_features_field>":{
  19. "model_id":"the model to produce the token weights",
  20. "model_text":"the query string"
  21. }
  22. }
  23. }
  24. }
  25. ----
  26. // TEST[skip: TBD]
  27. [discrete]
  28. [[text-expansion-query-params]]
  29. === Top level parameters for `text_expansion`
  30. `<rank_features_field>`:::
  31. (Required, object)
  32. The name of the field that contains the token-weight pairs the NLP model created
  33. based on the input text.
  34. [discrete]
  35. [[text-expansion-rank-feature-field-params]]
  36. === Top level parameters for `<rank_features_field>`
  37. `model_id`::::
  38. (Required, string)
  39. The ID of the model to use to convert the query text into token-weight pairs. It
  40. must be the same model ID that was used to create the tokens from the input
  41. text.
  42. `model_text`::::
  43. (Required, string)
  44. The query text you want to use for search.
  45. [discrete]
  46. [[text-expansion-query-notes]]
  47. === Notes
  48. The following is an example of the `text_expansion` query that references the
  49. ELSER model to perform semantic search. For a more detailed description of how
  50. to perform semantic search by using ELSER and the `text_expansion` query, refer
  51. to <<semantic-search-elser,this tutorial>>.
  52. [source,console]
  53. ----
  54. GET my-index/_search
  55. {
  56. "query":{
  57. "text_expansion":{
  58. "ml.tokens":{
  59. "model_id":".elser_model_1",
  60. "model_text":"How is the weather in Jamaica?"
  61. }
  62. }
  63. }
  64. }
  65. ----
  66. // TEST[skip: TBD]