Class MergingSuggestDataProvider

java.lang.Object
de.cxp.ocs.smartsuggest.spi.MergingSuggestDataProvider
All Implemented Interfaces:
SuggestDataProvider

public class MergingSuggestDataProvider extends Object implements SuggestDataProvider
Merges all the data it gets from all specified data providers. To distinguish the types afterwards, the suggest data type is added as tag to each according suggest record.
  • Constructor Details

    • MergingSuggestDataProvider

      public MergingSuggestDataProvider()
  • Method Details

    • hasData

      public boolean hasData(String indexName)
      Description copied from interface: SuggestDataProvider

      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.

      Specified by:
      hasData in interface SuggestDataProvider
      Parameters:
      indexName - identifier for the requested data
      Returns:
      if data is available
    • getLastDataModTime

      public long getLastDataModTime(String indexName)
      Description copied from interface: SuggestDataProvider

      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.

      Specified by:
      getLastDataModTime in interface SuggestDataProvider
      Parameters:
      indexName - identifier for the requested data
      Returns:
      unix timestamp in millis
    • loadData

      public SuggestData loadData(String indexName) throws IOException
      Specified by:
      loadData in interface SuggestDataProvider
      Parameters:
      indexName - identifier for the requested data
      Returns:
      suggest data
      Throws:
      IOException - if data couldn't be loaded