diff --git a/search-xapian/XS/StringValueRangeProcessor.xs b/search-xapian/XS/StringValueRangeProcessor.xs
index 95da8d3..cd4c9d3 100644
|
a
|
b
|
MODULE = Search::Xapian PACKAGE = Search::Xapian::StringValueRangeProcessor
|
| 3 | 3 | PROTOTYPES: ENABLE |
| 4 | 4 | |
| 5 | 5 | StringValueRangeProcessor * |
| 6 | | StringValueRangeProcessor::new(valueno valno) |
| | 6 | StringValueRangeProcessor::new(valno, str="", prefix = TRUE) |
| | 7 | valueno valno |
| | 8 | string str |
| | 9 | bool prefix |
| 7 | 10 | 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 3: |
| | 16 | case 4: { |
| | 17 | RETVAL = new StringValueRangeProcessor(valno, str, prefix); |
| | 18 | break; |
| | 19 | } |
| | 20 | default: |
| | 21 | croak("Bad parameter count for new"); |
| | 22 | } |
| 9 | 23 | OUTPUT: |
| 10 | 24 | RETVAL |
| 11 | 25 | |
diff --git a/search-xapian/t/parser.t b/search-xapian/t/parser.t
index ea0716a..1d12296 100644
|
a
|
b
|
|
| 6 | 6 | |
| 7 | 7 | use Test; |
| 8 | 8 | use Devel::Peek; |
| 9 | | BEGIN { plan tests => 58 }; |
| | 9 | BEGIN { plan tests => 60 }; |
| 10 | 10 | use Search::Xapian qw(:standard); |
| 11 | 11 | ok(1); # If we made it this far, we're ok. |
| 12 | 12 | |
| … |
… |
my $vrp2 = new Search::Xapian::NumberValueRangeProcessor(2);
|
| 85 | 85 | my $vrp3 = new Search::Xapian::StringValueRangeProcessor(3); |
| 86 | 86 | my $vrp4 = new Search::Xapian::NumberValueRangeProcessor(4, '$'); |
| 87 | 87 | my $vrp5 = new Search::Xapian::NumberValueRangeProcessor(5, 'kg', 0); |
| | 88 | my $vrp6 = new Search::Xapian::StringValueRangeProcessor(6, 'country:'); |
| | 89 | my $vrp7 = new Search::Xapian::StringValueRangeProcessor(7, ':name', 0); |
| 88 | 90 | $qp->add_valuerangeprocessor( $vrp1 ); |
| 89 | 91 | $qp->add_valuerangeprocessor( $vrp2 ); |
| 90 | 92 | $qp->add_valuerangeprocessor( $vrp4 ); |
| 91 | 93 | $qp->add_valuerangeprocessor( $vrp5 ); |
| | 94 | $qp->add_valuerangeprocessor( $vrp6 ); |
| | 95 | $qp->add_valuerangeprocessor( $vrp7 ); |
| 92 | 96 | $qp->add_valuerangeprocessor( $vrp3 ); |
| 93 | 97 | |
| 94 | 98 | $qp->add_boolean_prefix("test", "XTEST"); |
| … |
… |
foreach $pair (
|
| 108 | 112 | [ '12/03/99..12/04/01', 'VALUE_RANGE 1 19990312 20010412' ], |
| 109 | 113 | [ '03-12-99..04-14-01', 'VALUE_RANGE 1 19990312 20010414' ], |
| 110 | 114 | [ '(test:a..test:b hello)', '(hello:(pos=1) FILTER VALUE_RANGE 3 test:a test:b)' ], |
| | 115 | [ 'country:chile..denmark', 'VALUE_RANGE 6 chile denmark' ], |
| | 116 | [ 'albert..xeni:name', 'VALUE_RANGE 7 albert xeni' ], |
| 111 | 117 | ) { |
| 112 | 118 | my ($str, $res) = @{$pair}; |
| 113 | 119 | my $query = $qp->parse_query($str); |
diff --git a/xapian-core/docs/valueranges.rst b/xapian-core/docs/valueranges.rst
index 85a8df4..8b7d023 100644
|
a
|
b
|
would report::
|
| 60 | 60 | The ``VALUE_RANGE`` subquery will only match documents where value 4 is |
| 61 | 61 | >= asimov and <= bradbury (using a string comparison). |
| 62 | 62 | |
| | 63 | ``StringValueRangeProcessor`` also supports supplying a prefix or |
| | 64 | suffix, so the user is able to filter queries to a range within a |
| | 65 | specified value: |
| | 66 | |
| | 67 | prose country:chile..denmark |
| | 68 | |
| | 69 | This is done by providing the string to ``StringValueRangeProcessor``, |
| | 70 | like this: |
| | 71 | |
| | 72 | Xapian::QueryParser qp; |
| | 73 | Xapian::StringValueRangeProcessor country_proc(7, "country:", TRUE); |
| | 74 | qp.add_valuerangeprocessor(&country_proc); |
| | 75 | |
| | 76 | The parsed query will include ``(VALUE_RANGE 7 chile denmark)`` in |
| | 77 | this case. |
| | 78 | |
| | 79 | The last argument determines whether the string is a prefix or a |
| | 80 | suffix (like perhaps a currency indicator: 10..100$). |
| | 81 | |
| 63 | 82 | DateValueRangeProcessor |
| 64 | 83 | ======================= |
| 65 | 84 | |