learning-to-rank-search-usage.asciidoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. [[learning-to-rank-search-usage]]
  2. === Search using Learning To Rank
  3. ++++
  4. <titleabbrev>Search using LTR</titleabbrev>
  5. ++++
  6. NOTE: This feature was introduced in version 8.12.0 and is only available to certain subscription levels.
  7. For more information, see {subscriptions}.
  8. [discrete]
  9. [[learning-to-rank-rescorer]]
  10. ==== Learning To Rank as a rescorer
  11. Once your LTR model is trained and deployed in {es}, it can be used as a <<rescore, rescorer>> in the <<search-your-data, search API>>:
  12. [source,console]
  13. ----
  14. GET my-index/_search
  15. {
  16. "query": { <1>
  17. "multi_match": {
  18. "fields": ["title", "content"],
  19. "query": "the quick brown fox"
  20. }
  21. },
  22. "rescore": {
  23. "learning_to_rank": {
  24. "model_id": "ltr-model", <2>
  25. "params": { <3>
  26. "query_text": "the quick brown fox"
  27. }
  28. },
  29. "window_size": 100 <4>
  30. }
  31. }
  32. ----
  33. // TEST[skip:TBD]
  34. <1> First pass query providing documents to be rescored.
  35. <2> The unique identifier of the trained model uploaded to {es}.
  36. <3> Named parameters to be passed to the query templates used for feature.
  37. <4> The number of documents that should be examined by the rescorer on each shard.
  38. [discrete]
  39. [[learning-to-rank-rescorer-limitations]]
  40. ===== Known limitations
  41. [discrete]
  42. [[learning-to-rank-rescorer-limitations-window-size]]
  43. ====== Rescore window size
  44. Scores returned by LTR models are usually not comparable with the scores issued by the first pass query and can be lower than the non-rescored score. This can cause the non-rescored result document to be ranked higher than the rescored document. To prevent this, the `window_size` parameter is mandatory for LTR rescorers and should be greater than or equal to `from + size`.
  45. [discrete]
  46. [[learning-to-rank-rescorer-limitations-pagination]]
  47. ====== Pagination
  48. When exposing pagination to users, `window_size` should remain constant as each page is progressed by passing different `from` values. Changing the `window_size` can alter the top hits causing results to confusingly shift as the user steps through pages.
  49. [discrete]
  50. [[learning-to-rank-rescorer-limitations-negative-scores]]
  51. ====== Negative scores
  52. Depending on how your model is trained, it’s possible that the model will return negative scores for documents. While negative scores are not allowed from first-stage retrieval and ranking, it is possible to use them in the LTR rescorer.