1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
/**
* This class represents a numeric range. You can also specify the number of hits you want this range to produce,
* which can be used to create more efficient searches.
* Note that '0' as hit limit means all hits matching the range criterion will be a match,
* while positive numbers start from 'from' working
* its way towards 'to' until it has reached its limit or range is exhausted. Negative number means that it will start
* from 'to' and work its way towards 'from'.
*
* @author baldersheim
* @author bratseth
*/
// Note that this is just a convenience subclass of IntItem - it does not add any functionality not available in it.
public class RangeItem extends IntItem {
/**
* Creates a new range operator
*
* @param from inclusive start point for range
* @param to inclusive end point for range
* @param indexName the index to search for this range
*/
public RangeItem(Number from, Number to, String indexName) {
this(from, to, indexName, false);
}
/**
* Creates a new range operator
*
* @param from start point for range
* @param to end point for range
* @param indexName the index to search for this range
*/
public RangeItem(Limit from, Limit to, String indexName) {
this(from, to, indexName, false);
}
/**
* Creates a new range operator
*
* @param from inclusive start point for range
* @param to inclusive end point for range
* @param indexName the index to search for this range
* @param isFromQuery Indicate if this stems directly from the user given query,
* or if you have constructed it at will.
*/
public RangeItem(Number from, Number to, String indexName, boolean isFromQuery) {
this(from, to, 0, indexName, isFromQuery);
}
/**
* Creates a new range operator
*
* @param from start point for range
* @param to end point for range
* @param indexName the index to search for this range
* @param isFromQuery Indicate if this stems directly from the user given query,
* or if you have constructed it at will.
*/
public RangeItem(Limit from, Limit to, String indexName, boolean isFromQuery) {
this(from, to, 0, indexName, isFromQuery);
}
/**
*
* @param from inclusive start point for range
* @param to inclusive end point for range
* @param hitLimit This tells how many results you want included from this range as a minimum.
* You might get less if there are not enough, or you might get more. It will use the dictionary and
* include enough entries to satisfy your request.
* Positive number will start from left (@from) and work right.
* Negative number will start from right and work its way left.
* 0 means no limit.
* @param indexName the index to search for this range
* @param isFromQuery Indicate if this stems directly from the user given query,
* or if you have constructed it at will.
*/
public RangeItem(Number from, Number to, int hitLimit, String indexName, boolean isFromQuery) {
this(new Limit(from, true), new Limit(to, true), hitLimit, indexName, isFromQuery);
}
/**
*
* @param from start point for range
* @param to end point for range
* @param hitLimit This tells how many results you want included from this range as a minimum.
* You might get less if there are not enough, or you might get more. It will use the dictionary and
* include enough entries to satisfy your request.
* Positive number will start from left (@from) and work right.
* Negative number will start from right and work its way left.
* 0 means no limit.
* @param indexName the index to search for this range
* @param isFromQuery Indicate if this stems directly from the user given query,
* or if you have constructed it at will.
*/
public RangeItem(Limit from, Limit to, int hitLimit, String indexName, boolean isFromQuery) {
super(from, to, hitLimit, indexName, isFromQuery);
}
/** Returns the lower limit of this range, which may be negative infinity */
public final Number getFrom() {
return getFromLimit().number();
}
/** Returns the upper limit of this range, which may be positive infinity */
public final Number getTo() {
return getToLimit().number();
}
}
|