SCORE (Lakehouse v1)
Gibt die Relevanz der Abfragezeichenfolge zurück. Je höher der Score, desto relevanter sind die Daten. Bitte beachten Sie, dass die Funktion SCORE nur zusammen mit der Funktion QUERY oder MATCH verwendet werden kann.
Die Funktion SCORE von PlaidCloud Lakehouse ist von der Funktion SCORE in Elasticsearch inspiriert.
SQL Syntax
Abschnitt betitelt „SQL Syntax“SCORE()SQL Examples
Abschnitt betitelt „SQL Examples“CREATE TABLE test(title STRING, body STRING);
CREATE INVERTED INDEX idx ON test(title, body);
INSERT INTO test VALUES('The Importance of Reading', 'Reading is a crucial skill that opens up a world of knowledge and imagination.'),('The Benefits of Exercise', 'Exercise is essential for maintaining a healthy lifestyle.'),('The Power of Perseverance', 'Perseverance is the key to overcoming obstacles and achieving success.'),('The Art of Communication', 'Effective communication is crucial in everyday life.'),('The Impact of Technology on Society', 'Technology has revolutionized our society in countless ways.');
-- Retrieve documents where the 'title' column contains the keyword 'art' with a boost of 5 and the 'body' column contains the keyword 'reading' with a boost of 1.2, along with their relevance scoresSELECT *, score() FROM test WHERE QUERY('title:art^5 body:reading^1.2');
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ title │ body │ score() │├───────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼───────────┤│ The Importance of Reading │ Reading is a crucial skill that opens up a world of knowledge and imagination. │ 1.3860708 ││ The Art of Communication │ Effective communication is crucial in everyday life. │ 7.1992116 │└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
-- Retrieve documents where the 'title' column contains the keyword 'reading' with a boost of 5 and the 'body' column contains the keyword 'everyday' with a boost of 1.2, along with their relevance scoresSELECT *, score() FROM test WHERE MATCH('title^5, body^1.2', 'reading everyday');
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ title │ body │ score() │├───────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼───────────┤│ The Importance of Reading │ Reading is a crucial skill that opens up a world of knowledge and imagination. │ 8.585282 ││ The Art of Communication │ Effective communication is crucial in everyday life. │ 1.8575745 │└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘