Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order by a fulltext match column does not work #6530

Closed
timsehn opened this issue Aug 17, 2023 · 3 comments · Fixed by dolthub/go-mysql-server#1957
Closed

order by a fulltext match column does not work #6530

timsehn opened this issue Aug 17, 2023 · 3 comments · Fixed by dolthub/go-mysql-server#1957
Assignees
Labels
analyzer bug Something isn't working good repro Easily reproducible bugs

Comments

@timsehn
Copy link
Sponsor Contributor

timsehn commented Aug 17, 2023

Repro:

$ dolt init
$ dolt sql -q "create table ft (id int primary key, doc text, fulltext idx(doc)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
$ dolt sql -q "insert into ft values (1, 'This is text you bum'), (2, 'I hate dolts'), (3, 'Dolt is a sick database'), (4, 'Dolt dolt dolty dolt Dolt dolt')"
Query OK, 4 rows affected (0.01 sec)

$ dolt sql -q "select id, doc, match(doc) against('hate bum dolt') as relevance from ft order by relevance desc"
+----+--------------------------------+-----------+
| id | doc                            | relevance |
+----+--------------------------------+-----------+
| 1  | This is text you bum           | 7.0377927 |
| 2  | I hate dolts                   | 4.3801537 |
| 3  | Dolt is a sick database        | 4.2765365 |
| 4  | Dolt dolt dolty dolt Dolt dolt | 7.684004  |
+----+--------------------------------+-----------+

$ dolt sql -q "explain select id, doc, match(doc) against('hate bum dolt') as relevance from ft order by relevance desc"
+------------------------------------------------------------------------------------------------------------------+
| plan                                                                                                             |
+------------------------------------------------------------------------------------------------------------------+
| Sort(MATCH (ft.doc) AGAINST ('hate bum dolt' IN NATURAL LANGUAGE MODE) as relevance DESC)                        |
|  └─ Project                                                                                                      |
|      ├─ columns: [ft.id, ft.doc, MATCH (ft.doc) AGAINST ('hate bum dolt' IN NATURAL LANGUAGE MODE) as relevance] |
|      └─ Table                                                                                                    |
|          └─ name: ft                                                                                             |
+------------------------------------------------------------------------------------------------------------------+
@timsehn timsehn added bug Something isn't working analyzer good repro Easily reproducible bugs labels Aug 17, 2023
@timsehn
Copy link
Sponsor Contributor Author

timsehn commented Aug 17, 2023

Also, note it's unlikely the alias which was my first guess:

$ dolt sql -q "select id, doc, match(doc) against('hate bum dolt') as relevance from ft order by 3 desc"                
+----+--------------------------------+-----------+
| id | doc                            | relevance |
+----+--------------------------------+-----------+
| 1  | This is text you bum           | 7.0377927 |
| 2  | I hate dolts                   | 4.3801537 |
| 3  | Dolt is a sick database        | 4.2765365 |
| 4  | Dolt dolt dolty dolt Dolt dolt | 7.684004  |
+----+--------------------------------+-----------+

@timsehn
Copy link
Sponsor Contributor Author

timsehn commented Aug 17, 2023

The plot thickens

$ dolt sql -q "select id, doc, match(doc) against('hate bum dolt') as relevance from ft where relevance > 7"    
error on line 1 for query select id, doc, match(doc) against('hate bum dolt') as relevance from ft where relevance > 7: column "relevance" could not be found in any table in scope

@timsehn
Copy link
Sponsor Contributor Author

timsehn commented Aug 17, 2023

Apparently I am not good at sql.

$ dolt sql -q "select id, doc, match(doc) against('hate bum dolt') as relevance from ft having relevance > 7"
+----+--------------------------------+-----------+
| id | doc                            | relevance |
+----+--------------------------------+-----------+
| 1  | This is text you bum           | 7.0377927 |
| 4  | Dolt dolt dolty dolt Dolt dolt | 7.684004  |
+----+--------------------------------+-----------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer bug Something isn't working good repro Easily reproducible bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants