▼  Site Navigation Main Articles News Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc Links to Webcomics Bible Quotes About Older Musings
site version 7.3
Search –– change log
written by: admin


Date Written: 3/12/07 Last Updated: 5/29/15

Beta 1 My first attempt in creating a search feature to search the database.  This one searches the anime review's summary, basic premise, and conclusions for one typed in word.  

It will list some numbered results per page, 3 times what is requested, so if 4 results are requested then 12 results are displayed on each page.  Another problem is there may be 12 results on the first and second page, but 8 on the third and 4 on the last page.  It took a long time to figure out why.  The reason was because it would list all of the results from one column in the table until it ran out of matches and would not start listing the results from the next column in the table until a new page was up.  This version won't create links for each result.  The numbering system is also off.

Beta 2 With this version the numbering system has been fixed so that only ten results are displayed per page and no results are left out or duplicated.  This version required extensive changes to accomplish this.

Beta 3 This version demonstrates truncated results.

Truncating has to do with strlen() and substr().  strlen() is string length and substr() determines which section of characters in the string to return.  It should look something like this:  


$lmt=500;
if (strlen($text) > $lmt) {
$text = substr($text,0,$lmt);
echo "$text";}



Beta 4 This version demonstrates linking each result to where it was located.  In order to accomplish this I borrowed a short snippet of code from the anime review selection page where the links are auto generated and auto linked.  Several minor bugs have also been fixed with this version.  I have yet to fix the prev link in this version.

Beta 5 This version has the Prevs button fixed and has the ability to search for more than one word at a time with a limit of 5 terms.  Fixing the prevs button required extensive changes.  Being able to search for more than one term at a time in order to narrow down results was difficult to figure out, but required very few changes.

I did a tiny bit of cosmetics on the way the searches look making it look just a touch like the way Google does its results.  I don't want to do the full cosmetic work until last, so as not to clutter up the script.  The next beta version should include at least one of the following:


Search 1.1 This version searches manga reviews now.  The code was slightly cleaned up as well.

Here is a short example of a query

SELECT * FROM anime WHERE premise like \"%$terms1[0]%\" and premise like \"%$terms1[1]%\...


and

SELECT * FROM anime WHERE summary like \"%$terms1[0]%\" and premise like \"%$terms1[1]%\...


and many more queries for each column.


Search 1.2 The script has been simplified so that six while loops have been narrowed to a very efficient one by making use of arrays.  This took around three days to do and was not easy, however the result is that the code is simplified a bit and a little easier to understand and update.

Search 1.2.4 Version 1.3 is a big project, so I am going to update it in segments.  At present the script has been shortened significantly and simplified as well.  The prevs section of the script has been shortened and the manga links have been fixed as well.

Search 1.3 The script has been greatly simplified and has been condensed from 257 lines down to 189

Search 1.3.5 I have updated it so that 7 parts no longer need to be updated.  Still working on it.  Fixed the prevs bug  ...again.  I count about 4 lines and one section that need to be updated now and all of which can be yet eliminated.

search 1.4 The while loops now automatically know how many loops to run  

two of the big four lines have been rewritten so that they no longer need to be updated.  The search now has no limits on the number of search terms you can enter into a query A bug has been fixed as well.

Search 1.5 Eleven more lines in the easy to update section no longer need to be updated.  The links to the next page and prevs page now auto update.  This leaves 4 lines left that need to be updated when a new section is added.

This version's major features are that it dynamically searches the database and can be easily updated and adapted to different websites.



Search 2.0 beta 1 For some reason I have started up on this script again.  It is hard to figure out everything that I did, so I am rewriting it.  

This new version already has a beta 1 version that works.  I am not sure how long it will take before I replace the search feature that is already up.  This new version has a lot of reconstructive surgery that it needs.  Here is a short list.


Search 2.0 beta 2 This version is pretty much the same as the last version, but large parts have been edited out so as to recognize the slightly different design.  Links have been fixed.  Searches are faster, but the speed difference really is not very noticeable.

Here is an abridged version of what the new queries look like:

SELECT basic_premise, summary, conclusion FROM anime_review WHERE (basic_premise like \"%$terms1[0]%\" and basic_premise like \"%$terms1[4]%\") or (summary like \"%$terms1[0]...


I had to abridge it because the queries were huge, but I only needed one per table.  They also eliminated the duplicates problem from the first version.

Search 2.0 beta 3 This version will simplify the script.

I have been going over the script and noticed that all of the search scripts have searched for all of the terms entered and in any order with the exception of some of the earliest scripts, but the search is only returned if all of the terms are found in the one column.  

For example the terms 'none yet' are only found in certain reviews where either the basic premise or summary have not been written yet.  If I search for 'none yet is' there will be no results returned because the terms 'none', 'yet', and 'is' do not all appear together in the premise, summary, or body of the review even if they all do appear in the article.

Still working on the script.

I still want to finish scanning it for bugs first.  The next thing to work on will need to be allowing for unlimited terms in the search field.

I decided to create THIS version primarily because I wanted to eliminate duplicates that were still cropping up.  I made it 2.0 as opposed to 1.6 because I had to start over again almost from scratch.



Forget version 2!  I am going to move on to version 3!  I know that it has been a while since my last update, but it occured to me a while back that the results were not all that accurate in that the search of version 1 and 2 searched each category independantly so that all of the terms had to appear in a column together in order to qualify as a result.

Last night it occured to me how to get the search program to search the document as a whole, but only those columns that I wanted searched.  

You can concatenate them so that the columns are searched as one conglomerate as opposed to three seperate entities.  Sorry, I wish I could describe this better.  Take a look at the following code:


SELECT premise, summary, conclusion FROM review WHERE concat(premise, conclusion) like '%must%' and concat(premise,summary,conclusion) like '%storyline%'



In the above example 'must' and 'storyline' can appear together in the premise or together in the conclusion and it will equal a match.  However, the two terms can also occur seperately with 'must' occuring in premise and 'storyline' appearing in the conclusion and it will also match.  This wasn't possible in versions one or two.  The queries are also much much shorter.

The premise, summary and conclusion are all merged together and searched as a whole as opposed to searching each area independantly.

Search 3.0 test I updated the query part of the search and it worked beautifully.  I'll see if I can get some more updates to this program soon.  Gotta take care of a few things today yet.


The rest is looking good.  In case you are wondering I am working off of the Search 1.1 version that I did a while back.  I would have done a later version, but the program just looked too complicated, so I had to start with something I understood first.

Before I work on version 4 I will need to develop my understanding of Javascript.  The program will search in the normal way and then additional pages will simply do a query with a LIMIT added and replace the content of the first set of results without refreshing the page.

Actually, I think that I can add a virtual pagination script from dynamic drive and that will speed things up tremendously.  I can do the javascript thing later.

Search 3.1  (7/5/07) This version is rather amazing.  It uses the virtual pagination script from dynamic drive so that the query needs to only be done once.  It still needs a bit of work yet, but already it looks wonderful.

Another version that I am not so sure that I even want to try at this point would only execute a query when the "next" or "prevs" button is clicked.  However I think that I will add that feature only when the queries start to take too long to execute.

Search 3.2  (7/7/07) Added arrays to the program to ready it for the admin page.

Added 'title' to the list of cols searched.  

Added unlimited search terms to the search program.

Search 3.3  (7/17/07) This version is customizable with the admin page.  Two additional files were created for this version and a MySQL segment was set aside for it as well for a total of 3 files used to run the search program now.

Added the loops to the program.

Search 3.4 (7/20/07) This version is much easier to use.  All I have to do is type in the category to search and the program generates the rest of the code.  Lots of bug fixes as well, like links have been corrected and all of the verses in daily bible verse are searchable.  I made it so that the tables can be entered in any order.  In version 3.3 I had to enter in 4 additional columns for a total of 5 and keep track of the order that they were placed in in order for the program to run correctly or at all.

Search 3.5 (7/25/07) I added checkboxes to make selecting tables easier and look better.  

Search 3.6 (7/28/07) There were several bug fixes with this version that had to be taken care of before moving on to the next phase of this program.  In particular:

1.) The main content files and memoblog files are now accessible.  
2.) The subject of each result is now accurately listed and no longer has 'anime' as it's default.  
3.) My favorite bug fix is that the pagination links at the bottom of the page is now fixed in place allowing for faster clicking through the pages.

Search 3.7 (7/31/07) The public can now decide what parts of the site to search and can narrow the search by category.

Search 3.8 (10/13/08) Search terms are now lowercase to miss fewer results than before.

Search 3.9 (12/1/08) Search queries are now case insensitive so as not to miss results.

code was changed from
SELECT ID, ID, summary FROM memoblog WHERE ( concat(ID, summary) LIKE '%wordpress%' )
to
SELECT ID, ID, summary FROM memoblog WHERE (lcase( concat(ID, summary)) LIKE '%wordpress%' )


Search 3.10 (12/2/08) Major bugfix where the wrong tables were being searched or not searched.  This bug was introduced after sliming down the search program which was done after several tables in the database were removed.

Some bugs still remain:  
Search 3.11 (12/3/08)
Search 3.12 (12/9/08)
Search 3.13 (12/16/08)
Search 3.14 (4/12/09)
Search 3.15 (11/4/09)
SELECT ID, ID, summary FROM memoblog WHERE (lcase( concat(cast(ID as char), summary)) LIKE '%wordpress%' )

Search 3.16 (1/8/10)
Compared to either of the previous two versions this version is different in that the program really is faster.  The search queries are also more intelligent in that columns of text are merged and searched as one unit.  The script is simpler.  The searches are no longer case sensitive.  A sophisticated admin page was created that is very easy to use and has more options.  This version was created because I decided to head in a very different direction with my scripting by refining the queries.


Search 4.0 (1/14/10)Here is an example of the revised query to include NULL values:
SELECT ID, summary, image FROM memoblog WHERE (lcase( concat(cast(ID as char), summary, IFNULL(image,''))) LIKE '%yoo%' )

Search 4.1 (1/15/10)
Search 4.2 (1/16/10)
Search 4.3 (3/30/10)
Search 4.4 (3/30/10)
Search 4.5 (4/5/10)
This version was created to make the search boxes dynamic thus eliminating the need to update them manually any time the searchable tables and/or columns were altered.  Updating the search boxes was taking up half of the code for the search program.


Search 5.0 (5/6/10)
Search 5.1 (5/11/10)
Search 5.2 (8/24/10)
Search 5.3 (11/8/10)
Search 5.4 (6/28/11)
Search 5.5 (7/17/11)
Search 5.6 (12/26/11)
Search 5.7 (7/28/13)
Search 5.8 (5/29/15)
Search 5.x future
This version is different in that the queries now use UNION, which greatly simplifies and increases my control over sorting and limiting of the results.  Ajax pagination is now used, which greatly speeds up the load time of most searches.  LIMIT has been removed from the search query.  LIMIT is now determined via php instead and is no longer needed.


Useful links

text indexing
full text indexing dev.mysql.com

TAGS: website, search feature
copyright 2005–2024