T
- the type of items in the Iterator.public interface IndexHits<T> extends ResourceIterator<T>, ResourceIterable<T>
Iterator
with additional size()
and close()
methods on it, used for iterating over index query results. It is first and
foremost an Iterator
, but also an Iterable
JUST so that it
can be used in a for-each loop. The iterator()
method
always returns this
.
The size is calculated before-hand so that calling it is always fast.
When you're done with the result and haven't reached the end of the
iteration close()
must be called. Results which are looped through
entirely closes automatically. Typical use:
IndexHitshits = index.get( "key", "value" ); try { for ( Node node : hits ) { // do something with the hit } } finally { hits.close(); }
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying search result.
|
float |
currentScore()
Returns the score of the most recently fetched item from this iterator
(from
Iterator.next() ). |
T |
getSingle()
Returns the first and only item from the result iterator, or
null
if there was none. |
int |
size()
Returns the size of this iterable, in most scenarios this value is accurate
while in some scenarios near-accurate.
|
iterator
int size()
IndexHits
object has been returned when inside a Transaction
which has index modifications, of a certain nature. Also entities
(Node
s/Relationship
s) which have been deleted from the graph,
but are still in the index will also affect the accuracy of the returned size.void close()
close
in interface AutoCloseable
close
in interface Resource
close
in interface ResourceIterator<T>
T getSingle()
null
if there was none. If there were more than one item in the result a
NoSuchElementException
will be thrown. This method must be called
first in the iteration and will grab the first item from the iteration,
so the result is considered broken after this call.null
if none.float currentScore()
Iterator.next()
). The range of the returned values is up to the
Index
implementation to dictate.Copyright © 2002–2014 The Neo4j Graph Database Project. All rights reserved.