[Xapian-discuss] Filtering Search Results By Date in PHP

Benny Chan misterchan at gmail.com
Thu Jul 26 18:51:41 BST 2007


Hello All,

I am trying to make it so that I can do things like "cat
1/23/2004..5/24/2005" but I am getting back 0 results. Here is my index
script:

         document_id: field=ref unique=Q boolean=Q
         document_title: field=title weight=100 unhtml index=S
         url: field=url
         document_text: field=document_text unhtml index
         abstract: field=abstract
         doc_date: field=doc_date date=yyyymmdd
         category: field=category boolean=XC


I can then index documents fine and search them regularly using the
following PHP:

        $query_parser = new_queryparser();

        $rp = new_datevaluerangeprocessor(1, true);
        queryparser_add_valuerangeprocessor($rp);

        //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");
        //add prefix so you can search within titles
        queryparser_add_prefix($query_parser, "title", "S");

        //parse and create the query
        $query = queryparser_parse_query($query_parser,
strtolower($_REQUEST["search"]));

I proceed to index one document only with the date "20050101". I then try
the query string "20010101..20070101" which is a pretty wide range, but I
get no results. I'm thinking that I may be entering the query string
incorrectly or I may be calling the function incorrectly in the php code.
The indexing of the document seems to be ok. If anyone can shed some light
on this, I would appreciate it a lot. Thanks for reading.

Benny


More information about the Xapian-discuss mailing list