[Xapian-discuss] PHP Bindings... Infinite Loop?

Ryan Mahoney ryan at frameweld.com
Wed Dec 27 19:48:50 GMT 2006


I recently upgraded to version 0.9.9 of the php bindings.  I am running 
Apache 2.2.3 and PHP 5.2.  I have re-indexed all my data with the latest 
version of scriptindex.  The data set I have is somewhat small, maybe 
4000 items.  When I run a query, it completes quickly, but as I run a 
few more (maybe 2 or 3), the Apache process goes out of control, using 
up 1 CPU completely on a 4 CPU linux server.  Any ideas?  We have not 
had this problem in older versions of Xapian.  I don't have any problems 
searching with simplesearch.

Thanks for any help!

-r

- - -
Below is the PHP code currently being used
- - -
                //load the module
                dl ("xapian.so");

                $db = new_database($database_name);
                $stemmer = new_stem("english");

                //create a query parser
                define('FLAG_BOOLEAN', 1);
                $query_parser = new_queryparser();

                //set the stemmer and turn on the stemming strategy
                queryparser_set_stemmer($query_parser, $stemmer);
                queryparser_set_stemming_strategy($query_parser, 1);

                //set the database
                queryparser_set_database($query_parser, $db);

                //set prefix
                queryparser_add_boolean_prefix($query_parser, 
"category", "XC");

                //count elements in each category
                foreach($category as $cat_id => $cat_name) {
                        //parse and create the query
                        $cat_query = 
queryparser_parse_query($query_parser, $_REQUEST["search"] . " 
category:" . $cat_id);
                        $cat_enq = new_enquire($db);
                        enquire_set_query($cat_enq, $cat_query);
                        $cat_result_set = enquire_get_mset($cat_enq, 0, 
10000);
                        $cat_total = 
mset_get_matches_estimated($cat_result_set);
                        $category_count[$cat_id] = $cat_total;
                }

                //get the results for the page itself
                //set prefix
                if (strlen(trim($_REQUEST["level2"])) > 0) {
                        $append = " category:" . $_REQUEST["level2"];
                } else {
                        $append = '';
                }

                //parse and create the query
                $query = queryparser_parse_query($query_parser, 
$_REQUEST["search"] . $append);
                $enq = new_enquire($db);
                enquire_set_query($enq, $query);

                //handle numbering
                if (strlen(trim($_REQUEST["page"])) < 1) {
                        $_REQUEST["page"] = 1;
                }
                $results_per_page = 30;
                $begin = ($_REQUEST["page"] * $results_per_page) - 
$results_per_page;
                $result_set = enquire_get_mset($enq, 0, 10000);
                $item = mset_begin($result_set);
                $total = mset_get_matches_estimated($result_set);

                $pages = ceil($total / $results_per_page);

                //reset array
                $item = mset_begin($result_set);
- - -




More information about the Xapian-discuss mailing list