[Xapian-discuss] Value field Query and case sensitivity

Colin Bell colinabell at gmail.com
Thu Apr 10 12:14:52 BST 2008


I think this solves it. I'll try it out today.

 From http://xapian.org/docs/valueranges.html
Custom subclasses

You can easily create your own subclasses of  
Xapian::ValueRangeProcessor. Your subclass needs to implement a method  
Xapian::valuenooperator()(std::string &begin, std::string &end) so for  
example you could implement a better version of the author range  
described above which only matches ranges with a prefix (e.g.  
author:asimov..bradbury) and lower-cases the names:

struct AuthorValueRangeProcessor : public Xapian::ValueRangeProcessor {
     AuthorValueRangeProcessor() {}
     ~AuthorValueRangeProcessor() {}

     Xapian::valueno operator()(std::string &begin, std::string &end) {
         if (begin.substr(0, 7) != "author:")
             return Xapian::BAD_VALUENO;
         begin.erase(0, 7);
         begin = Xapian::Unicode::tolower(term);
         end = Xapian::Unicode::tolower(term);
         return 4;
     }
};

On 10 Apr 2008, at 12:09, James Aylett wrote:

> On Thu, Apr 10, 2008 at 12:05:32PM +0100, Colin Bell wrote:
>
>> The data held in the value fields are displayed during search  
>> results,
>> so things like names of authors etc need to maintain their proper  
>> noun
>> case sensitivity.
>
> Are you using the document data for anything? If not, put the display
> stuff in there, and make the values lowercased; values are really
> intended to be used internally in most cases.
>
> J
>
> -- 
> /--------------------------------------------------------------------------\
>  James Aylett                                                   
> xapian.org
>  james at tartarus.org                                
> uncertaintydivision.org
>
> _______________________________________________
> 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