Ticket #607: 0001-Add-support-for-3-arg-version-of-StringValueRangePro.patch

File 0001-Add-support-for-3-arg-version-of-StringValueRangePro.patch, 2.0 KB (added by Adam Sjøgren, 12 years ago)
  • search-xapian/XS/StringValueRangeProcessor.xs

    diff --git a/search-xapian/XS/StringValueRangeProcessor.xs b/search-xapian/XS/StringValueRangeProcessor.xs
    index 95da8d3..792f99e 100644
    a b MODULE = Search::Xapian PACKAGE = Search::Xapian::StringValueRangeProcessor  
    33PROTOTYPES: ENABLE
    44
    55StringValueRangeProcessor *
    6 StringValueRangeProcessor::new(valueno valno)
     6StringValueRangeProcessor::new(valno, str="", prefix = TRUE)
     7    valueno valno
     8    string str
     9    bool prefix
    710    CODE:
    8         RETVAL = new StringValueRangeProcessor(valno);
     11        switch (items) { /* items includes the hidden this pointer */
     12        case 2:
     13            RETVAL = new StringValueRangeProcessor(valno);
     14            break;
     15        case 4: {
     16            RETVAL = new StringValueRangeProcessor(valno, str, prefix);
     17            break;
     18        }
     19        default:
     20            croak("Bad parameter count for new");
     21        }
    922    OUTPUT:
    1023        RETVAL
    1124
  • xapian-core/docs/valueranges.rst

    diff --git a/xapian-core/docs/valueranges.rst b/xapian-core/docs/valueranges.rst
    index 85a8df4..8b7d023 100644
    a b would report::  
    6060The ``VALUE_RANGE`` subquery will only match documents where value 4 is
    6161>= asimov and <= bradbury (using a string comparison).
    6262
     63``StringValueRangeProcessor`` also supports supplying a prefix or
     64suffix, so the user is able to filter queries to a range within a
     65specified value:
     66
     67    prose country:chile..denmark
     68
     69This is done by providing the string to ``StringValueRangeProcessor``,
     70like this:
     71
     72    Xapian::QueryParser qp;
     73    Xapian::StringValueRangeProcessor country_proc(7, "country:", TRUE);
     74    qp.add_valuerangeprocessor(&country_proc);
     75
     76The parsed query will include ``(VALUE_RANGE 7 chile denmark)`` in
     77this case.
     78
     79The last argument determines whether the string is a prefix or a
     80suffix (like perhaps a currency indicator: 10..100$).
     81
    6382DateValueRangeProcessor
    6483=======================
    6584