Jump to content

Recommended Posts

Working with importing data from a tab delimited file. Recently, I'm wanting to add a new search feature that would search an address -- which is spread across numerous fields.

For example, 123 E. Main St. is separated into four separate fields. The number, direction (east), street name, and street type (like street, boulevard, avenue, etc).

So, if I have a single search field where they can type "123 Main" I'd like it to combine the four fields in a single search. Does that make sense?

The other option is to make a separate "combined" field in the database where I run the four address fields together on import.

Is there a mysql solution, or do I need to create the separate field?
Link to comment
https://forums.phpfreaks.com/topic/4846-searching-like-across-numerous-fields/
Share on other sites

The most ideal way to handle this is to create a FULLTEXT index which contains all of the columns that make up your semantic address field. There are plenty of examples in the refman -- once you have it set up, you can issue a "MATCH...AGAINST" query to find the desired rows. There are some subtleties to using this versus using "LIKE" (e.g. stopwords, word length, etc.), so read carefully!

Hope that helps.
Hmm... Getting very close. Any idea why Boolean mode would be giving me an error?

[code] SELECT *
FROM  `listings`
WHERE MATCH (
STREET_NUM, STREET_NAME
)
AGAINST (
'+7653 +Cameron'
IN BOOLEAN
MODE
);

#1064 - You have an error in your SQL syntax near 'BOOLEAN MODE)' at line 1
[/code]
  • 2 weeks later...
okay -- I dropped a line on the plesk forum and got an answer rather quickly. It just took me this long to build up the courage to do it.

It was a single command on the command line ("yum upgrade mysql"), followed by a tweak of the /etc/my.cnf file.

After much nail biting, and hair standing up on the back of my neck, etc, it actually turned out to be very simple and completely pain free.

Anyway, the indexing works better than I could have imagined, thanks for the help.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.