public class LuceneSearchProvider extends Object implements SearchProvider
| Modifier and Type | Field and Description |
|---|---|
static int |
LUCENE_SEARCH_TIMEOUT_MS |
| Constructor and Description |
|---|
LuceneSearchProvider(String luceneIndexPath,
int maxResults)
Constructor.
|
LuceneSearchProvider(String luceneIndexPath,
int maxResults,
int searchTimeout)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearDimension()
Clears the dimension cache, and resets the indices, effectively resetting the SearchProvider to a clean state.
|
Pagination<DimensionRow> |
findAllDimensionRowsPaged(PaginationParameters paginationParameters)
Return the desired page of dimension rows.
|
TreeSet<DimensionRow> |
findAllOrderedDimensionRows()
Getter for dimension rows in tree set for consistent order.
|
Pagination<DimensionRow> |
findFilteredDimensionRowsPaged(Set<ApiFilter> filters,
PaginationParameters paginationParameters)
Return the desired page of dimension rows that match the specified filters.
|
int |
getDimensionCardinality()
Gets the number of distinct dimension rows (assuming the key field is unique) in the index.
|
boolean |
isHealthy()
Method to check if search provider is healthy.
|
void |
refreshIndex(Map<String,HashDataCache.Pair<DimensionRow,DimensionRow>> changedRows)
Method to add / update indexes.
|
void |
refreshIndex(String rowId,
DimensionRow dimensionRow,
DimensionRow dimensionRowOld)
Refresh lucene index
|
void |
replaceIndex(String newLuceneIndexPathString)
Replaces index with a new index in hot-swap manner.
|
void |
setDimension(Dimension dimension)
Setter for dimension.
|
void |
setKeyValueStore(KeyValueStore keyValueStore)
Setter for store.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindAllDimensionRows, findFilteredDimensionRows, hasAnyRowspublic LuceneSearchProvider(String luceneIndexPath, int maxResults, int searchTimeout)
luceneIndexPath - Path to the lucene index filesmaxResults - Maximum number of allowed results in a pagesearchTimeout - Maximum time in milliseconds that a lucene search can runpublic LuceneSearchProvider(String luceneIndexPath, int maxResults)
luceneIndexPath - Path to the lucene index filesmaxResults - Maximum number of allowed results in a pagepublic void setDimension(Dimension dimension)
SearchProvidersetDimension in interface SearchProviderdimension - Dimension the SearchProvider is searchingpublic void setKeyValueStore(KeyValueStore keyValueStore)
SearchProvidersetKeyValueStore in interface SearchProviderkeyValueStore - KeyValueStore that holds the data rows indexed by the Search Providerpublic int getDimensionCardinality()
SearchProvidergetDimensionCardinality in interface SearchProviderpublic Pagination<DimensionRow> findAllDimensionRowsPaged(PaginationParameters paginationParameters)
SearchProviderfindAllDimensionRowsPaged in interface SearchProviderpaginationParameters - The parameters that define a page (i.e. the number of rows per page,
and the page of results desired)public TreeSet<DimensionRow> findAllOrderedDimensionRows()
SearchProviderfindAllOrderedDimensionRows in interface SearchProviderpublic boolean isHealthy()
SearchProviderisHealthy in interface SearchProviderpublic void refreshIndex(String rowId, DimensionRow dimensionRow, DimensionRow dimensionRowOld)
Query the lucene indexes on key column to see if there are any existing indexes.
If yes, then we need to update the indexes. Update is done by first deleting the existing documents and then adding new ones.
If not, then just add the documents to indexes.
refreshIndex in interface SearchProviderrowId - key for id columndimensionRow - the new dimension rowdimensionRowOld - the dimension row with which the index needs to be added / updatedpublic void refreshIndex(Map<String,HashDataCache.Pair<DimensionRow,DimensionRow>> changedRows)
SearchProviderrefreshIndex in interface SearchProviderchangedRows - Collection of newRow / oldRow pairs keyed by rowId to update the index with. Each row is a
pair of dimension rows (newRow is the key, oldRow is the value), with the rowId (ie. unique key in the dimension)
as the top-level Map key.public void replaceIndex(String newLuceneIndexPathString)
SearchProviderreplaceIndex in interface SearchProvidernewLuceneIndexPathString - The location of directory that contains the the new index.public void clearDimension()
Note that this method attempts to acquire a write lock before clearing the index.
clearDimension in interface SearchProviderpublic Pagination<DimensionRow> findFilteredDimensionRowsPaged(Set<ApiFilter> filters, PaginationParameters paginationParameters)
SearchProviderfindFilteredDimensionRowsPaged in interface SearchProviderfilters - ApiFilters to use for finding matching dimension rowspaginationParameters - The parameters that define a page (i.e. the number of rows per page,
and the page of results desired)
Throws TimeoutException If the search times out.Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.