search.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. *Input*: None, *Output*: `double`
  12. Returns the {defguide}/relevance-intro.html[relevance] of a given input to the executed query.
  13. The higher score, the more relevant the data.
  14. NOTE: When doing multiple text queries in the `WHERE` clause then, their scores will be
  15. combined using the same rules as {es}'s
  16. <<query-dsl-bool-query,bool query>>.
  17. Typically `SCORE` is used for ordering the results of a query based on their relevance:
  18. ["source","sql",subs="attributes,callouts,macros"]
  19. ----
  20. include-tagged::{sql-specs}/docs.csv-spec[orderByScore]
  21. ----
  22. However, it is perfectly fine to return the score without sorting by it:
  23. ["source","sql",subs="attributes,callouts,macros"]
  24. ----
  25. include-tagged::{sql-specs}/docs.csv-spec[scoreWithMatch]
  26. ----