473,468 Members | 1,323 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

searching rows containig a substring fast

I am creating a server indexing files in my local area network, in
order to provide a searching feature.
So i want to make it possible to searchsuch rows where the 'name'
(VARCHAR) column contains a substring submitted by user.
an i use a full-text index to make it faster? from my first sight i
noticed that this index can be used to search for words in a string. So

the example below would not go:
searching 'cool' in 'uncoolness'
Am i right? Are there any other solutions? Maby some other databases
provide this use case?
thx

Dec 26 '05 #1
2 7957
If you want to search for text strings that appear within a word, use
the wildcard character %. For example

SELECT * FROM tablename WHERE columname LIKE "%cool%"

would find records that contain the word cool even if the word has
other characters around it. The wildcard character % seems to be
equivalent to .* in regular expressions - it matches zero or more
instances of any possible character. You will (naturally) need to
replace 'tablename' and columnname with the name of the table and
column that you want to search.

Michael

Dec 27 '05 #2
That's a toughie. A regular index won't let you to substring searches
(you have to start at the beginning), so it won't work.

If you're using InnoDB, a fulltext won't work either It's a MyISAM
feature.

If you decide to use a FULLTEXT index, make sure that you have enough
rows in your table (at least 3) - and keep in mind that unless you do a
boolean search the 50% rule will apply (which means if someone searches
for names containing the letters 'an' and 'an' appears in more than 50%
of the rows, they'll get no results)

If you're doing a whole lot of this and are very interested in
performance, I'd recommend you look at lucene - it's performance is
much better than MySQL's fulltext.

Also, be aware that by default FULLTEXT will only index strings that
are longer than 3 characters. You might want/need to change that if
you are indexing names (since you want "Tom", "Ed", and "Bo" to be
indexed - or whatever 3 character file names that you have).

Dec 31 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Peter Guetens | last post by:
Hi, How can one search a value on all fields in a table is this possible ? thanks Peter
7
by: junky_fellow | last post by:
Can anyone suggest some efficient way to search a substring in a text file. For eg. suppose i want to search the pattern "abc" in a text file, then which algorithm should i use. I just want some...
9
by: C3 | last post by:
I have to process some data in C that is given to me as a char * array. I have a fairly large number of substrings (well, they're not actually printable, but let's treat them as strings) that I...
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
5
by: sree078 | last post by:
Hi I've a list of Values with varchar field in main in a table. I wanted to have fast search as there are very less insertions/updations. Thought to do a FullText Searching on that varchar field....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.