Simple Searching plan **Let's start by aiming for the following scenario: The searcher is presented with two boxes, one to type in, one that is a pull-down list of: Anywhere, Title, Author, Subject (a shorter version of the Spydus interface, we'll save the more complex stuff for the Thorough Search). The searcher enters a term, chooses a search type, hits enter, and is presented with search results formatted as in our current templates (but in a more logical order). **Here's what goes on behind the scenes: The goal is to return a sorted list of bibid's from the initial SQL statement, then pass those bibid's through new SQL statements on the "old" Koha tables to get the values that will be used by the templates. The initial SQL used depends on the search type: Anywhere search - The SQL is SELECT DISTINCT bibid FROM marc_subfield_table WHERE subfield_value LIKE "term1% term2% term3%" An alternate SQL could be SELECT DISTINCT bibid FROM marc_word WHERE word LIKE "term1%" OR word LIKE "term2%" OR word LIKE "term3%" The first SQL is by far the more accurate and by far the slower. If the searcher typed in "great locomotive chase" for example, the first search finds one hit in 20 seconds, the second finds 5389 hits in a little over 1 second. My assumption is that the searcher wants "great locomotive chase" and not every record that has the word "great" in it, and that the first SQL is the better. Title search - The SQL is SELECT DISTINCT bibid FROM bibliotitles WHERE title LIKE "term1% term2% term3%" ORDER BY title,author There is no table called bibliotitles -- yet. I'm proposing that we make one and use it as our title indexing file. The table would have three columns: bibid, title (a varchar column used as primary key) and author. Whenever we imported new MARC records, ALL the title fields would be stripped of any non-filing characters (according to the tag indicator) and loaded into bibliotitles. This means that records added manually, such as magazines, would not show up in a 'title' search, but would appear in an 'anywhere' search. The bibliotitles table allows us to get rid of the unwanted "the," "an," and "a" words at the beginning of titles that mess up our title sorts. Author search - The SQL is SELECT DISTINCT marc_subfield_table.bibid, subfieldvalue, title FROM marc_subfield_table, bibliotitles WHERE (tag="100" OR tag="700") AND (subfieldvalue LIKE "term3% term1%" OR subfieldvalue LIKE "term1% term3%") AND marc_subfield_table.bibid=bibliotitles.bibid ORDER BY subfieldvalue,title OK, this one's a little odd in it's handling of the terms, because it uses only the first and the last terms, and it tests them in both orders. This is because the searcher might enter "Henry Longfellow" or "Henry Wadsworth Longfellow" or "Longfellow, Henry" or "Longfellow, Henry Wadsworth" -- and yes, that last one does work! (I'm assuming that commas are stripped from the entry.) Even things like "Garcia Marquez, Gabriel" work, because we test the search terms in both orders. This search is very fast. Note that we are again using the new bibliotitles table to get the title sort right. Subject search - Actually, I think the existing subject search is good enough, even though the titles are going to be out of strict order. Unless we want to sort results by call number?