[Xapian-discuss] Using boolean terms in PHP bindings

Ryan Mahoney ryan at frameweld.com
Wed Mar 29 23:55:21 BST 2006


OK, I figured out how to implement this properly, have to say, it wasn't 
so intuitive!  Maybe after this project I will try to work on some extra 
tutorials for the PHP bindings.  Here's the code correction:

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

    //parse and create the query
    $query = queryparser_parse_query ($query_parser, $_REQUEST["search"] 
. " category:22");


Ryan Mahoney wrote:
> 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);
>
>
> _______________________________________________
> Xapian-discuss mailing list
> Xapian-discuss at lists.xapian.org
> http://lists.xapian.org/mailman/listinfo/xapian-discuss
>
>
>
>





More information about the Xapian-discuss mailing list