question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MATCH AGAINST Syntax

See original GitHub issue

This is such a good library and amazing use of TypeScript inference.

The challenge I have is that I need to be able to issue a query that includes MATCH AGAINST for a field that is indexed as FULLTEXT but can’t seem to figure out the safe, correct syntax.

I can do it like this: query.where(sql`MATCH(the_field_name) AGAINST (${someValue} IN NATURAL LANGUAGE MODE)`);

However, I rather this was parameterised, something like this: query.where(sql`MATCH(the_field_name) AGAINST (? IN NATURAL LANGUAGE MODE)`, '=', someValue);

The latter example builds a query that looks like: where MATCH(EL_Notes_Dispo) AGAINST (? IN NATURAL LANGUAGE MODE) = ?

Whereas I’d like for the ? placeholder to be substituted. Is there some syntax that I can use in Kysely to achieve this?

(P.S. I’d love to join the Discord to ask this kind of question but the chat link on Github shows an invitation expired error)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
koskimascommented, Jun 14, 2022

Your first example IS parametrized. Just take a look at the generated SQL. The sql template tag takes care of the parametrization. It doesn’t actually interpolate the value into the SQL.

0reactions
rcoundoncommented, Jun 14, 2022

I created a temporary invite for you. Does this work: https://discord.com/invite/fBTbXtat

Perfect - that worked, thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

MATCH AGAINST - MariaDB Knowledge Base
Syntax. MATCH (col1,col2,...) AGAINST (expr [search_modifier]). Description. A special construct used to perform a fulltext search on a fulltext index.
Read more >
12.10.2 Boolean Full-Text Searches - MySQL :: Developer Zone
This mimics the behavior of MATCH() AGAINST() without the IN BOOLEAN MODE modifier. @ distance. This operator works on InnoDB tables only. It...
Read more >
mysql match against ~ example - Stack Overflow
A collection is a set of one or more columns included in a FULLTEXT index. The search string is given as the argument...
Read more >
How the MATCH() Function Works in MySQL - Database.Guide
In MySQL, the MATCH() function performs a full-text search. It accepts a comma separated list of table columns to be searched.
Read more >
MySQL Full text search - w3resource
Therefore create the index after loading data. MySQL Version: 5.6. Syntax: MATCH (col1,col2,col3...) AGAINST (expr [search_modifier]).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found