search.asciidoc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[sql-functions-search]]
  4. === Full-Text Search Functions
  5. Search functions should be used when performing full-text search, namely
  6. when the `MATCH` or `QUERY` predicates are being used.
  7. Outside a, so-called, search context, these functions will return default values
  8. such as `0` or `NULL`.
  9. [[sql-functions-search-score]]
  10. ==== `SCORE`
  11. .Synopsis:
  12. [source, sql]
  13. --------------------------------------------------
  14. SCORE()
  15. --------------------------------------------------
  16. *Input*: _none_
  17. *Output*: `double` numeric value
  18. .Description:
  19. Returns the {defguide}/relevance-intro.html[relevance] of a given input to the executed query.
  20. The higher score, the more relevant the data.
  21. NOTE: When doing multiple text queries in the `WHERE` clause then, their scores will be
  22. combined using the same rules as {es}'s
  23. <<query-dsl-bool-query,bool query>>.
  24. Typically `SCORE` is used for ordering the results of a query based on their relevance:
  25. ["source","sql",subs="attributes,callouts,macros"]
  26. ----
  27. include-tagged::{sql-specs}/docs.csv-spec[orderByScore]
  28. ----
  29. However, it is perfectly fine to return the score without sorting by it:
  30. ["source","sql",subs="attributes,callouts,macros"]
  31. ----
  32. include-tagged::{sql-specs}/docs.csv-spec[scoreWithMatch]
  33. ----