Home > info > Faster and Better Search Support

Faster and Better Search Support

November 3rd, 2012

Just a short update! The free image gallery phtagr got some awesome changes regarding the media searches. The most exciting feature is the support of inclusion, optional and exclusion search terms.

As usual for the search /tag:flower/tag:tree/category:nature/location:-germany the terms flower, tree, and nature are required (AND operation). The location must not have germany.

If you change the term category:nature to category:+nature the search becomes different. For /tag:flower/tag:tree/category:+nature/location:-germany the terms flower and tree become optional and do not need to match. The category nature is now required and the location must not have germany. Therefore, the plus sign changes the search term from optional to required. The result is ordered by the hit count of the search terms. Media with tag flower and tree are higher ranked as media with only a flower tag. Media without tags flower and tree are shown at least.

To get an optional search you can use /tag:flower/tag:tree/category:nature/location:-germany/operand:OR and at least one of the terms flower, tree, and nature must exist while germany is excluded.

With this change you can query your media set faster and easy to the desired sub set.

The second great change is a database schema change. Previously, phtagr used for tags, categories and locations two tables each (e.g. one table to hold the tag name and one to store the tag assignment to images). The sql query building was complex and slow to support inclusion and exclusion of search terms. Now these 6 tables are unified to two tables and simplifies the query building and reduced the execution time.

If you upgrade, open phtagr/setup in your browser to trigger the automatic database upgrade (and it does not hurt to keep a database backup before upgrading). Further, depending on your size of phtagr installation, this database migration might consume some time and memory. Some limit adaptions need to be done to php.ini if the upgrade does not work in the first run. I needed to increase my memory limit from 128M to 256M (memory_limit = 256M) in my /etc/php5/apache2/php.ini to migrate 2643 fields with 90203 media assignment of 20725 photos.

[update 2012-11-09]The query speed for search term exclusion was recently optimized to handle exclusions in seconds for 20k media instead of several seconds. The exclusion is done via a NOT IN () in WHERE condition block with a subquery.[/update]

The newest tarball could be downloaded from sourceforge as usual. Or try the demo gallery demo.phtagr.org with location:+italy/category:vacation/location:lecce/category:-screenshots!

Categories: info Tags:
Comments are closed.