search.asciidoc 1.1 KB

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