Interface SuggestDataProvider
-
- All Known Implementing Classes:
DummySuggestDataProvider,ElasticsearchSuggestDataProvider,MergingSuggestDataProvider
public interface SuggestDataProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidconfigure(Map<String,Object> config)Optional method that may be called to configure the data provider.longgetLastDataModTime(String indexName)Get the timestamp from when the data was modified the last time.booleanhasData(String indexName)Respond with 'true' if this provider is generally able to provide data for the requested index.SuggestDataloadData(String indexName)
-
-
-
Method Detail
-
configure
default void configure(Map<String,Object> config)
Optional method that may be called to configure the data provider. If a configuration is provided, it will be called once directly after instantiation.- Parameters:
config-
-
hasData
boolean hasData(String indexName)
Respond with 'true' if this provider is generally able to provide data for the requested index. This is a quick check when initializing the suggesters, so it should not take too long.
It's also possible to return a static "true" here and do the expensive availability check at the getLastDataModTime method, which is called async. If getLastDataModTime returns a value < 0, data update are canceled as well.
- Parameters:
indexName- identifier for the requested data- Returns:
-
getLastDataModTime
long getLastDataModTime(String indexName) throws IOException
Get the timestamp from when the data was modified the last time. For every change of that timestamp, the data will be pulled and indexed into suggest index.
Setting the timestamp at the data is optional, but if it is set there, it MUST be the same timestamp, otherwise the data is rejected. This feature is used to avoid potential concurrency issues.
If data is not available at all, a value < 0 should be returned.
- Parameters:
indexName- identifier for the requested data- Returns:
- unix timestamp in millis
- Throws:
IOException
-
loadData
SuggestData loadData(String indexName) throws IOException
- Parameters:
indexName- identifier for the requested data- Returns:
- suggest data
- Throws:
IOException
-
-