I am trying to use the range attribute.
For testing, I use a search that returns 3 records without a range, and I set the range 0-1, which should return only the first 2. However, I get all 3 results.
Here is how I do it:
String rangeStr = attribute + ";range=0-1";
String returnedAttrs[] = {rangeStr, attribute};
_searchControls.setReturningAttributes(returnedAttrs);
_searchControls.setSearchScope(scope);
NamingEnumeration<SearchResult> answer = _context.search(name, filter, _searchControls);
List<String> result = new LinkedList<String>();
while (answer != null && answer.hasMoreElements())
{
Attribute currentAttr = answer.next().getAttributes().get(attribute);
if (currentAttr == null)
continue;
for (int i=0; i<currentAttr.size(); i++)
{
String val = currentAttr.get(i).toString();
result.add(val);
}
}
What am I doing wrong?
I use a page size of 1000, but if I understand correctly, this should not affect long-range searches (given that the page size is larger than the specified range). It is right?
source
share