Can Pre-Appended Wildcards be Used in MySQL Fulltext Search?

  • Thread starter dduardo
  • Start date
  • Tags
    Mysql
In summary, The conversation discusses the possibility of using pre-appended wildcards in a fulltext search and whether there are any workarounds available. The individual has already read through the documentation and found that only appended wildcards are allowed. They also mention using the LIKE function with % on both ends of each word, but needing the ability to use boolean operators for advanced searching and sorting the query by relevance. They then mention talking to some individuals in a mysql chatroom and being recommended to write their own search engine due to the slow speed of fulltext. They also ask for recommendations on efficient indexing algorithms for databases.
  • #1
dduardo
Staff Emeritus
1,905
3
Do you guys know if it is possible to use pre-appended wildcards when doing a fulltext search? Is there a workaround that I could possibly use? I've read through the documentation and it seems as if you can only do appended wildcards. Here is my query:

Code:
$query = "SELECT title, MATCH (title) AGAINST ('" . $search . "' IN BOOLEAN MODE) AS relevance FROM descriptions WHERE MATCH (title)  AGAINST ('" . $search . "*' IN BOOLEAN MODE) ORDER BY relevance DESC"

I know I can use LIKE with % on both ends of each word, but I need the ability to use boolean operators for advanced searching and have my query sorted by relevance.
 
Last edited:
Computer science news on Phys.org
  • #2
Ok, I just talked to some guys over at the mysql chatroom on freenode. They recommended writing my own search engine since fulltext is slow.

If anyone has worked with databases before can you recommend an efficient indexing algorithms.
 
Last edited:
  • #3


Yes, it is possible to use pre-appended wildcards when doing a fulltext search in MySQL. The workaround is to use the asterisk symbol (*) at the beginning of your search term and enclose it in quotes, like this: '"*"search term"'. This will allow you to use boolean operators and sort by relevance in your query.
 

1. What are the wildcards available for fulltext searching in MySQL?

MySQL offers two wildcards for fulltext searching: asterisk (*) and percent sign (%). The asterisk wildcard represents zero or more characters, while the percent sign wildcard represents zero or more words.

2. How are wildcards used in fulltext searching in MySQL?

Wildcards are used in conjunction with the MATCH() and AGAINST() functions in MySQL to perform fulltext searches. The MATCH() function specifies the columns to be searched, while the AGAINST() function specifies the search query, which can include wildcards.

3. Can wildcards be used in combination with other search operators in fulltext searching?

Yes, wildcards can be used in combination with other search operators such as AND, OR, and NOT in fulltext searching in MySQL. This allows for more complex and specific search queries.

4. Are there any limitations to using wildcards in fulltext searching in MySQL?

Yes, there are some limitations to using wildcards in MySQL fulltext searching. Wildcards cannot be used with the NEAR operator, and they cannot be used at the beginning of a word or phrase. Additionally, wildcard searches are case-insensitive.

5. How can I optimize wildcard searches in MySQL for better performance?

To optimize wildcard searches in MySQL for better performance, it is recommended to use the asterisk wildcard sparingly and to avoid using it at the beginning of a word or phrase. Additionally, it is important to properly index the columns being searched and to limit the number of rows being searched by using other search operators in conjunction with wildcards.

Similar threads

  • Computing and Technology
Replies
18
Views
5K
  • Programming and Computer Science
Replies
7
Views
403
  • Computing and Technology
Replies
2
Views
612
  • Computing and Technology
Replies
1
Views
1K
  • Science and Math Textbooks
Replies
2
Views
715
Replies
1
Views
1K
  • High Energy, Nuclear, Particle Physics
Replies
7
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Beyond the Standard Models
Replies
3
Views
2K
  • Mechanical Engineering
Replies
3
Views
573
Back
Top