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

Andreas Marienborg andreas at startsiden.no
Mon Aug 6 07:16:38 BST 2007


On Jul 26, 2007, at 11:27 PM, Benny Chan wrote:

> OK,
>
> I found my mistake below. I actually left out the friggin'  
> queryparser:
>
>        $query_parser = new_queryparser();
>
>        $rp = new_datevaluerangeprocessor(1, true);
>        queryparser_add_valuerangeprocessor($query_parser, $rp);
>
> So now I can search for ranges and stuff. When I use a search  
> string like
>
> "1/1/2000..1/1/2007"
>
> I print out the parsed query and get:
>
> VALUE_RANGE 1 20000101 20070101
>
> I look at the term list for a document and it shows
>
> D20050101 1 1
> M200501 1 1
> Y2005 1 1
>
> So I'm thinking the documents are being indexed correctly. BUT I'm  
> still not
> getting any results. Any ideas guys?? = ( Thanks for reading.
>
> Benny
>
>

The ValueRange stuff works on Values, not Terms, so you need to  
inspect your documents, and make sure that value #1 is the date.

- andreas


>
> On 7/26/07, Benny Chan <misterchan at gmail.com> wrote:
>>
>> 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
>>
> _______________________________________________
> 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