public abstract class Searcher extends Object implements Iterable<Vector>
Modifier and Type | Field and Description |
---|---|
protected DistanceMeasure |
distanceMeasure |
Modifier | Constructor and Description |
---|---|
protected |
Searcher(DistanceMeasure distanceMeasure) |
Modifier and Type | Method and Description |
---|---|
abstract void |
add(Vector vector)
Add a new Vector to the Searcher that will be checked when getting
the nearest neighbors.
|
void |
addAll(Iterable<? extends Vector> data)
Adds all the data elements in the Searcher.
|
void |
addAllMatrixSlices(Iterable<MatrixSlice> data)
Adds all the data elements in the Searcher.
|
void |
addAllMatrixSlicesAsWeightedVectors(Iterable<MatrixSlice> data) |
void |
clear() |
static org.apache.lucene.util.PriorityQueue<WeightedThing<Vector>> |
getCandidateQueue(int limit)
Returns a bounded size priority queue, in reverse order that keeps track of the best nearest neighbor vectors.
|
DistanceMeasure |
getDistanceMeasure() |
boolean |
remove(Vector v,
double epsilon) |
List<List<WeightedThing<Vector>>> |
search(Iterable<? extends Vector> queries,
int limit) |
abstract List<WeightedThing<Vector>> |
search(Vector query,
int limit)
When querying the Searcher for the closest vectors, a list of WeightedThing
|
List<WeightedThing<Vector>> |
searchFirst(Iterable<? extends Vector> queries,
boolean differentThanQuery) |
abstract WeightedThing<Vector> |
searchFirst(Vector query,
boolean differentThanQuery)
Returns the closest vector to the query.
|
abstract int |
size()
Returns the number of WeightedVectors being searched for nearest neighbors.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, iterator, spliterator
protected DistanceMeasure distanceMeasure
protected Searcher(DistanceMeasure distanceMeasure)
public DistanceMeasure getDistanceMeasure()
public abstract void add(Vector vector)
public abstract int size()
public abstract List<WeightedThing<Vector>> search(Vector query, int limit)
query
- the vector to search forlimit
- the number of results to returnpublic List<List<WeightedThing<Vector>>> search(Iterable<? extends Vector> queries, int limit)
public abstract WeightedThing<Vector> searchFirst(Vector query, boolean differentThanQuery)
query
- the vector to search fordifferentThanQuery
- if true, returns the closest vector different than the query (this
only matters if the query is among the searched vectors), otherwise,
returns the closest vector to the query (even the same vector).public List<WeightedThing<Vector>> searchFirst(Iterable<? extends Vector> queries, boolean differentThanQuery)
public void addAll(Iterable<? extends Vector> data)
data
- an iterable of WeightedVectors to add.public void addAllMatrixSlices(Iterable<MatrixSlice> data)
data
- an iterable of MatrixSlices to add.public void addAllMatrixSlicesAsWeightedVectors(Iterable<MatrixSlice> data)
public boolean remove(Vector v, double epsilon)
public void clear()
public static org.apache.lucene.util.PriorityQueue<WeightedThing<Vector>> getCandidateQueue(int limit)
limit
- maximum size of the heap.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.