1

Topic: The search function

Just wondering whether it would be plausible to implement a full string option to the search as well the keywords loop? Had a quick look at search.php, and just wondered if where this occurs:

while (list($i, $word) = @each($keywords_array))

if actually doing a separate query with the keywords, (imploded into a single string), would actually work, or would the existing db lookup throw a wobbler? big_smile


Thanks again,

Matt

2

Re: The search function

Just answering my own question here. big_smile T'would appear it works fine. Quick question though, if I might? How come a full string search has never been added into the search function, as well as the individual keyword search? It only appears to require an extra four or five lines of code, to do a simple implode and straight lookup on the full string as entered.

Re: The search function

A lookup where? In the posts table?
I don't know that I understand what you mean tongue

4 (edited by MattF 2008-01-06 21:04)

Re: The search function

In the search.php script, the words entered into the search box are split and each one searched separately from the db, as standard, are they not? From what I can see, nowhere within search.php is a db query done upon the single, complete string entered into the search box as is, (as a whole), or have I missed something somewhere?

Re: The search function

Correct, because the single string is not necessarily the exact string someone is searching for.

6 (edited by MattF 2008-01-06 21:31)

Re: The search function

Can't fault that reasoning. big_smile

Would it not be a worthwhile addition, however, to the search function, to make an option in the search box, (i.e: if someone can remember a snippet from a thread, and they wish to hone the search), would it not be better to have a checkbox that would do a full string search only, if selected, and a split keyword search if not?

Re: The search function

MattF wrote:

to make an option in the search box

Or allow the use of quotation marks.

"search phrase here"

8 (edited by MattF 2008-01-06 23:06)

Re: The search function

A checkbox is less code to work on. big_smile Just tried the checkbox method on the downloads search script, and it seems to work rather well. smile http://forums.bauchan.org/testforum/dsearch.php There are only two items in that section, but try the term 'http download' with and without the box checked.

Would anybody be interested in having a modified search.php done to play around with and test for this full string search?

Re: The search function

I would Matt big_smile

10

Re: The search function

I'll get one knocked together. big_smile

11

Re: The search function

Well, once I figured out the search cache/table was killing the full string searches, big_smile it seems I have a working one for testing with. big_smile It needs one extra entry in lang/[language]/search.php:

'Search full'   =>    'Search for the complete string as entered. [ If not selected, each word entered will be searched for separately. ]',

and here's the link to the file:

http://outgoing.bauchan.org/unix/search.txt


I've only given it a quick test, but it appears to be working as expected. big_smile If the full string checkbox isn't selected/ticked, it defaults back to the standard way of searching.

Re: The search function

I am running it on http://shedrockonline.com - I had to do a file comparison because the version for Mega Pun has been modified. Although, I must admit that I don't see a difference in the search results. Maybe I am doing something wrong. sad

13

Re: The search function

Go to the search page and enter these two words in the keywords box: 'web application'

With the box unchecked, you will get three results. With the box checked, you will get one result. smile

14 (edited by bingiman 2008-01-07 02:28)

Re: The search function

hmm...It does work. Thanks Matt. big_smile

This is a much more sensible way to search.

15

Re: The search function

Glad you like it. smile

The beauty of it is the fact that very little extra code is needed, and all it does is use the multibyte method of searching, so nothing changes with regards to how the search function works. Plus, one still has the option of doing searches the old fashioned way. big_smile

Re: The search function

The use of quotation marks is supported in 1.3 with MySQL.

17

Re: The search function

Jansson wrote:

The use of quotation marks is supported in 1.3 with MySQL.

MySQL only, or PgSQL too? I would have thought that would be down to input parsing rather than db type.

Re: The search function

Because it's in FULLTEXT, which is only supported for MySQL.

19

Re: The search function

elbekko wrote:

Because it's in FULLTEXT, which is only supported for MySQL.

So does that relate specifically to the search cache/index tables themselves, then, and not searching the db directly as in the multibyte? method.

Re: The search function

No, it searches the posts/topics itself, no more search index.

It's a MySQL feature.

21

Re: The search function

I must be missing something here. big_smile What is the difference between using the fulltext search, and just searching a string of several words using the LIKE command?, as is used at the moment?

Re: The search function

Quite a bit wink
http://dev.mysql.com/doc/refman/5.0/en/ … earch.html

23 (edited by MattF 2008-01-08 22:53)

Re: The search function

Unless I'm mistaking what that info means, it's basically a case of you're dropping the PunBB search tables, and letting MySQL create it's own and then using MySQL's builtin fulltext search command(s)?

All other db types in 1.3 will just do searches as in 1.2.*?

Re: The search function

You're right, except that MySQL isn't creating a table, just indexing a column. We're letting MySQL handle the search for 1.3.

25

Re: The search function

I thought I might have misunderstood it slightly. I only gave it a cursory browse. (There appears to be a good several hours reading there). big_smile