How is the search function suposed to work?

danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Sat, 2009-07-25 15:34

I am back playing with G3 and I can not get the search function to work.
I have put a keyword into the description field and as a tag but I am still not able to search for it.
The only search I gotten to work is if I search for an exact Title or exact Filename.
Is this the expected behavior or should I be able to search for parts of the Title/Description/Filename/Tags?
(In G2 I can search for my Keywords - which I use extensively)

Regards,
--Dan

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2009-07-26 06:11

I think, (I hope really) that there is still work to be done on that. For example, I have a photo title Fred_03. Searching for Fred, finds nothing. But searching for Fred_03 will find the photo.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Thu, 2009-07-30 01:04

It should find words that you put into your description, and if you get the latest code and rebuild your search index (in mysql, do "truncate search_records" then go to Admin > Maintenance) then it'll index tags too.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Thu, 2009-07-30 16:31

Great, I'll try in a few days and come back with the result.
--
Dan

 
danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Tue, 2009-08-04 18:09

Today I finally got around to upgrade to the latest nightly release (gallery-gallery3-7ad0808a117fd1db4e94da8d7763ccca1d69350a.zip).
I can now see in the search_records table that the Tag entry is there:

mysql> select * from search_records where data like '%Per%';
+----+---------+-------+----------------------------+
| id | item_id | dirty | data                       |
+----+---------+-------+----------------------------+
| 28 |      28 |     0 |  dsc02756.jpg dsc02756 Per |
+----+---------+-------+----------------------------+
1 row in set (0.02 sec)

But when I do a search (Per or per) it still does not show.
--
Dan

 
danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Tue, 2009-08-04 18:18

I have been playing a little bit more and found the following:

1) If I add a Tag to a photo using the "Edit this photo", the search_records table does not get updated.
2) A bit more troublesome is that the search for "Per" in my last post does not fail due to a bug or such in G3 - it is mysql's MATCH ... AGAINST construct that "filers" this. If I set the Tag to "Robert" it get found as it should. The problem for me is that I planned to use the Tag function to record the name of the persons in the photo and in Swedish we have a lot names the are short (like Dan, Per, ...).

--
Dan

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2009-08-05 03:09

1) http://sourceforge.net/apps/trac/gallery/ticket/617 -- good catch!
2) http://sourceforge.net/apps/trac/gallery/ticket/618 -- this will be harder to fix. :-( I have no ideas about that currently.

---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Wed, 2009-08-05 17:32

For (2) I have found the reason for not finding the text and a dirty workaround.

The reason for not finding "Per" is twofold:
a) The default min length in mysql for search words are 4 chars.
b) The word "per" is in the default "Stop-Word-File" (mysql source file: storage/myisam/ft_static.c) and will not be considered in the search.

And here is my workaround:
In the mysql configuration file I had to add the following two lines to the [mysqld] section.

ft_min_word_len=2
ft_stopword_file=''

And rebuild the search_records table

mysql> REPAIR TABLE search_records QUICK;
+-----------------------+--------+----------+----------+
| Table                 | Op     | Msg_type | Msg_text |
+-----------------------+--------+----------+----------+
| dev_g3.search_records | repair | status   | OK       |
+-----------------------+--------+----------+----------+
1 row in set (0.00 sec)

Now I can search for "Per" and it gets found.

mysql> SELECT * FROM search_records WHERE MATCH(search_records.data) AGAINST ('per' IN BOOLEAN MODE);
+----+---------+-------+----------------------------+
| id | item_id | dirty | data                       |
+----+---------+-------+----------------------------+
| 28 |      28 |     0 |  dsc02756.jpg dsc02756 Per |
+----+---------+-------+----------------------------+
1 row in set (0.00 sec)

The big drawback with this approach is that this effects the whole mysql-server, so if you have other DB's in the same server where you use the fulltext search its behavior gets changed as well.

--
Dan

 
chivocrespo

Joined: 2010-11-02
Posts: 44
Posted: Sun, 2010-11-28 17:35

Sorry, but I can't find were in the mysql to add the two lines that allow the search with less than 4 characters. Can someone explain me with more detail? Please

 
danjoh
danjoh's picture

Joined: 2009-01-17
Posts: 21
Posted: Sun, 2010-11-28 17:47

On my box its in /etc/mysql/my.cnf in the [mysqld] section.
Like This:

# grep "\[mysqld\]" -A 2 my.cnf 
[mysqld]
ft_min_word_len=2
ft_stopword_file=''

--
Dan

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2012-04-05 18:54