Forum Moderators: coopster

Message Too Old, No Replies

optimizing search results in a tag photo search

         

omoutop

12:28 pm on Sep 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hello and thanks for any tips

I am building a small search engine for a website, to allow users to search photos there - either by photo name, photo description or photo tags.

My problem is that results are somewhat messed if the search term is small enough to belong to many words with diferent meanings.

for example:
i search the term "ios", which is a greek island
in my results i find photos marked with tag "agios", which means 'saint' in greek.

Is there a way to avoid such silly results? I dont want to limit the minimum characters beacause i will loose many usefull keywords

My queries look like this:
SELECT field FROM table WHERE LOWER(tag_field) LIKE '%$keyword%'
- $keyword is the search term, in lowercase
- tag_field has comma seperated words used as tags
- i have 2 more queries for photo name and photo description

jatar_k

4:47 pm on Sep 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could put spaces around it and then it wouldn't look for it inside other words

SELECT field FROM table WHERE LOWER(tag_field) LIKE '% $keyword %'

I would play with that to be sure it produced the desired results though, you could look at regexp in queries but speed may become an issue. You could look at putting spaces around the field value as well if that normalized the search results

omoutop

6:20 am on Sep 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for the idea.. nice trick
seems to work ok for now