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, wait
findAllDimensionRows, findFilteredDimensionRows, hasAnyRows
public 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)
SearchProvider
setDimension
in interface SearchProvider
dimension
- Dimension the SearchProvider is searchingpublic void setKeyValueStore(KeyValueStore keyValueStore)
SearchProvider
setKeyValueStore
in interface SearchProvider
keyValueStore
- KeyValueStore that holds the data rows indexed by the Search Providerpublic int getDimensionCardinality()
SearchProvider
getDimensionCardinality
in interface SearchProvider
public Pagination<DimensionRow> findAllDimensionRowsPaged(PaginationParameters paginationParameters)
SearchProvider
findAllDimensionRowsPaged
in interface SearchProvider
paginationParameters
- The parameters that define a page (i.e. the number of rows per page,
and the page of results desired)public TreeSet<DimensionRow> findAllOrderedDimensionRows()
SearchProvider
findAllOrderedDimensionRows
in interface SearchProvider
public boolean isHealthy()
SearchProvider
isHealthy
in interface SearchProvider
public 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 SearchProvider
rowId
- 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)
SearchProvider
refreshIndex
in interface SearchProvider
changedRows
- 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)
SearchProvider
replaceIndex
in interface SearchProvider
newLuceneIndexPathString
- 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 SearchProvider
public Pagination<DimensionRow> findFilteredDimensionRowsPaged(Set<ApiFilter> filters, PaginationParameters paginationParameters)
SearchProvider
findFilteredDimensionRowsPaged
in interface SearchProvider
filters
- 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.