[Xapian-discuss] Using boolean terms in PHP bindings

Ryan Mahoney ryan at frameweld.com
Wed Mar 29 22:29:28 BST 2006


OK, I'm indexing my data with the scriptindex.  I want to be able to 
restrict the search by the category field.  Do I need to do anything to 
the data itself?  Like, literally prefix it with the characters "XC"?  
Below is my indexor for scriptindex and the my php code...

document_id : field=ref unique=Q boolean=Q
search_id : field=document_id index=S
document_title : field=title weight=3 unhtml index
landing_page : field=landing_page
document_text : field=document_text unhtml index
abstract: field=abstract
category: field=category boolean=XC

- - - - - -
php
- - - - - -

    //load the module
    dl ("xapian.so");
   
    //report all errors
    error_reporting (E_ALL);

    $db = new_database ("/www/servers/util/omega/test/default");
    $stemmer = new_stem ("english");

    //create a query parser
    $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, "XC", "1");

    //parse and create the query
    $query = queryparser_parse_query ($query_parser, $_REQUEST["search"]);
    $enq = new_enquire ($db);
    enquire_set_query ($enq, $query);
    $result_set = enquire_get_mset ($enq, 0, 10);
    $item = mset_begin ($result_set);




More information about the Xapian-discuss mailing list