Creating a search function to search 1000+ text files?

I have custom coded a content management system which basically organizes articles into categories. Each article is represented by a text file which is analogous to a database record. I normally use PHP/MySQL but I opted to use text files here for my own reasons. Each text file has the same format, and stores the title, author, date, article text, and a few other fields. So anyhow, I would like to add search functionality to the site. Here are my thoughts so far:

  1. First I would have some function/routine that would take all the text files, and create some kind of super large index file.

  2. Then there would be a routine that could search this index file and return the best matching articles.

3) Alternately I could create a routine to export all of the articles to MySQL, and the website would use MySQL solely for the purpose of the search function.

Any thoughts or ideas?


You may want to take a look at MySQL’s FULLTEXT search functionalities :slight_smile:

Note that these only work on MyISAM tables, not on InnoDB.

PS. Now that this has become a MySQL question, do you want me to move this thread to the MySQL forum?

Check out the MySQL manual for Full Text functions and examples, there’s plenty there. :wink:

Silly me…can we just delete this thread and I’ll create a new one in the mysql forum?

And thanks for the link guys, I’m checking it out now.

Ok, that’s what I assumed would be best…so let’s say I create a table with the following fields:


And I would have one record for each article. I’m not totally sure where to go from here, I’ve never implemented a search feature before :o

Yep, 3. The others are silly.

/runs :stuck_out_tongue: