PDA

View Full Version : Pekka Search photo description


malum
10th of September 2003 (Wed), 10:26
Quick question (I did a search but couldn't find the answer)

How many words can the users put into the search function?
Will it search for any of the words, the exact phrase, or something else?
Thanks

Nick

Version 1.3

Pekka
11th of September 2003 (Thu), 04:40
EE has hardcoded wildcards (%) in the beginning and end of the string. This means keyword

graph

finds

photographer
graphic
siggraph

You can use spaces

g ca

finds

big car
lag caused

You can also use wildcard % in the middle or search phrase:

ni%n

finds

Niina Sapattinen
Jouni Miettinen
Nissan

One character wildcard is _ (underscore), so

t_e

finds

tie
toe
tee

To search whole words (or numbers) add one space before and one after the keyword:

{space}hit{space}

finds only word hit

hit

finds also the dirty word :oops:

Search is case-insensitive.

If you'd like to remove the hardcoded pre and post wildcards just replace in list.php AND photo.php


// wildcard before keyword
$wildcard1 = "%";

// wildcard after keyword
$wildcard2 = "%";


with


// wildcard before keyword
$wildcard1 = "";

// wildcard after keyword
$wildcard2 = "";

malum
11th of September 2003 (Thu), 07:06
Thank you, you are a gent :)

Is there a way to make it non case sensitive?

Pekka
11th of September 2003 (Thu), 13:07
malum wrote:
Thank you, you are a gent :)

Is there a way to make it non case sensitive?

Yes there is: but I'd like to make it optional and into UI as most people will be confused by it. It's one of the easiest things to HARDcode, though:

Non case-sensitive:

$search = "AND {$search_row} LIKE '{$wildcard1}{$keyword}{$wildcard2}'";

Case sensitive:

$search = "AND {$search_row} LIKE BINARY '{$wildcard1}{$keyword}{$wildcard2}'";

malum
12th of September 2003 (Fri), 11:50
Thanks yet again

malum
5th of May 2005 (Thu), 05:12
Resurrecting this as it seems to have changed in 1.5

I have removed the % as above to remove the auto wildcard from the search but this makes the serch function not work (it won't find anything it just returns 'no Images found' etc. when there should be plenty).

How do I remove the auto wildcard from the serch in 1.5?

Thanks

malum
12th of May 2005 (Thu), 10:31
Bump

help please Pekka: how to turn off automatic wildcard in the search function

Pekka
12th of May 2005 (Thu), 13:46
Well, it is done a said in this post and it works, it's not changed in 1.5. When you remove wildcards, the search string must match the whole search field. E.g. if you have image name "House of the rising sun" then you have to search "house of the rising sun" to get it. If you have space in the end of the title, the you must seach for "house of the rising sun " to get it. If you seek from description you must search for the whole description to get a hit. That is why wildcards are really useful.

In 1.5 RC4 you can add URL parameter strict_search=1 to enable exact search (no wildcards), e.g. http://photography-on-the.net/gallery/list.php?exhibition=1&search_row=all&keyword=Welcome to the Land of Sardins&strict_search=1

malum
12th of May 2005 (Thu), 14:13
So a 200 word description would need a 200 word search string matching it exactly?

Is there a way to search for single words in the description
i.e 'hot' would find all Instances of the word 'hot' in the description but not 'hots' or 'shot' etc ?

Pekka
12th of May 2005 (Thu), 14:28
So a 200 word description would need a 200 word search string matching it exactly?

Yes, that is so when you remove wildcards.

Is there a way to search for single words in the description
i.e 'hot' would find all Instances of the word 'hot' in the description but not 'hots' or 'shot' etc ?

Add spaces to it (when wildcards are in use):

" hot "

This will get you words inside a sentence. You might need to search for "hot " (beginning of sentence) or " hot." (end of sentence), too.

malum
12th of May 2005 (Thu), 14:51
Thank you