@Bindable(prefix="OpenSearchDocumentSource") public class OpenSearchDocumentSource extends MultipageSearchEngine
IDocumentSource fetching Documents (search results) from an
OpenSearch feed.
Based on code donated by Julien Nioche.
MultipageSearchEngine.SearchEngineResponseCallable, MultipageSearchEngine.SearchMode, MultipageSearchEngine.SearchRange| Modifier and Type | Field and Description |
|---|---|
Map<String,String> |
feedUrlParams
Additional parameters to be appended to
feedUrlTemplate on each request. |
String |
feedUrlTemplate
URL to fetch the search feed from.
|
int |
maximumResults
Maximum number of results.
|
int |
resultsPerPage
Results per page.
|
String |
userAgent
User agent header.
|
searchModecompressed, documents, POSTPROCESSING, query, results, resultsTotal, SERVICE, start, statistics| Constructor and Description |
|---|
OpenSearchDocumentSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
beforeProcessing()
Invoked after the attributes marked with
Processing and Input
annotations have been bound, but before a call to IProcessingComponent.process(). |
protected Callable<SearchEngineResponse> |
createFetcher(MultipageSearchEngine.SearchRange bucket)
Subclasses should override this method and return a
Callable instance that
fetches search results in the given range. |
void |
process()
Performs the processing required to fulfill the request.
|
collectDocuments, process, runQueryafterFetch, clean, urlEncodeafterProcessing, dispose, getContext, getSharedExecutor, initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterProcessing, dispose, init@Input @Processing @Attribute @Required @Label(value="Feed URL template") @Level(value=BASIC) @Group(value="Service") public String feedUrlTemplate
${variable}. The following
variables are supported:
searchTerms will be replaced by the querystartIndex index of the first result to be searched. Mutually
exclusive with startPagestartPage index of the first result
to be searched. Mutually exclusive with startIndex.count the number of search results per pageExample URL feed templates for public services:
http://www.nature.com/opensearch/request?interface=opensearch&operation=searchRetrieve&query=${searchTerms}&startRecord=${startIndex}&maximumRecords=${count}&httpAccept=application/rss%2Bxmlhttp://www.indeed.com/opensearch?q=${searchTerms}&start=${startIndex}&limit=${count}@Input @Processing @Attribute @Required @IntRange(min=1) @Label(value="Results per page") @Level(value=BASIC) @Group(value="Service") public int resultsPerPage
@Input @Processing @Attribute @IntRange(min=1) @Label(value="Maximum results") @Level(value=BASIC) @Group(value="Service") public int maximumResults
@Input @Processing @Attribute @Label(value="Feed URL parameters") @Level(value=ADVANCED) @Group(value="Service") public Map<String,String> feedUrlParams
feedUrlTemplate on each request.@Input @Processing @Attribute @Label(value="User agent") @Level(value=ADVANCED) @Group(value="Service") public String userAgent
null value is provided,
the following User-Agent will be sent: Rome Client (http://tinyurl.com/64t5n)
Ver: UNKNOWN.public void beforeProcessing()
IProcessingComponentProcessing and Input
annotations have been bound, but before a call to IProcessingComponent.process(). In this
method, the processing component should perform any initializations based on the
runtime attributes. This method is called once per request.beforeProcessing in interface IProcessingComponentbeforeProcessing in class ProcessingComponentBasepublic void process()
throws ProcessingException
IProcessingComponentprocess in interface IProcessingComponentprocess in class ProcessingComponentBaseProcessingException - when processing failed. If thrown, the
IProcessingComponent.afterProcessing() method will be called and the component will
be ready to accept further requests or to be disposed of. Finally, the
exception will be rethrown from the controller method that caused the
component to perform processing.protected Callable<SearchEngineResponse> createFetcher(MultipageSearchEngine.SearchRange bucket)
MultipageSearchEngineCallable instance that
fetches search results in the given range.
Note the query (if any is required) should be passed at the concrete class level. We are not concerned with it here.
createFetcher in class MultipageSearchEnginebucket - The search range to fetch.