@InputRequirement(value=INPUT_FORBIDDEN) @EventDriven @SupportsBatching @Tags(value={"elasticsearch","query","scroll","read","get","http"}) @CapabilityDescription(value="Scrolls through an Elasticsearch query using the specified connection properties. This processor is intended to be run on the primary node, and is designed for scrolling through huge result sets, as in the case of a reindex. The state must be cleared before another query can be run. Each page of results is returned, wrapped in a JSON object like so: { \"hits\" : [ <doc1>, <doc2>, <docn> ] }. Note that the full body of each page of documents will be read into memory before being written to a Flow File for transfer.") @WritesAttribute(attribute="es.index",description="The Elasticsearch index containing the document") @WritesAttribute(attribute="es.type",description="The Elasticsearch document type") @Stateful(description="After each successful scroll page, the latest scroll_id is persisted in scrollId as input for the next scroll call. Once the entire query is complete, finishedQuery state will be set to true, and the processor will not execute unless this is cleared.", scopes=LOCAL) public class ScrollElasticsearchHttp extends AbstractElasticsearchHttpProcessor
| Modifier and Type | Field and Description |
|---|---|
private static String |
FIELD_INCLUDE_QUERY_PARAM |
static PropertyDescriptor |
FIELDS |
private static String |
FINISHED_QUERY_STATE |
static PropertyDescriptor |
INDEX |
static PropertyDescriptor |
PAGE_SIZE |
static PropertyDescriptor |
QUERY |
private static String |
QUERY_QUERY_PARAM |
static Relationship |
REL_FAILURE |
static Relationship |
REL_SUCCESS |
static PropertyDescriptor |
SCROLL_DURATION |
private static String |
SCROLL_ID_QUERY_PARAM |
private static String |
SCROLL_ID_STATE |
private static String |
SCROLL_QUERY_PARAM |
private static String |
SIZE_QUERY_PARAM |
static PropertyDescriptor |
SORT |
private static String |
SORT_QUERY_PARAM |
static PropertyDescriptor |
TYPE |
CONNECT_TIMEOUT, ES_URL, PROXY_HOST, PROXY_PORT, RESPONSE_TIMEOUTCHARSET, PASSWORD, PROP_SSL_CONTEXT_SERVICE, USERNAME| Constructor and Description |
|---|
ScrollElasticsearchHttp() |
| Modifier and Type | Method and Description |
|---|---|
private URL |
buildRequestURL(String baseUrl,
String query,
String index,
String type,
String fields,
String sort,
String scrollId,
int pageSize,
String scroll) |
private void |
finishQuery(StateManager stateManager) |
private void |
getPage(okhttp3.Response getResponse,
URL url,
ProcessContext context,
ProcessSession session,
FlowFile flowFile,
ComponentLog logger,
long startNanos) |
Set<Relationship> |
getRelationships() |
List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
private boolean |
isQueryFinished(StateManager stateManager) |
private String |
loadScrollId(StateManager stateManager) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
saveScrollId(StateManager stateManager,
String scrollId) |
void |
setup(ProcessContext context) |
createElasticsearchClient, customValidate, getClient, isSuccess, parseJsonResponse, sendRequestToElasticsearchonTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateprivate static final String FINISHED_QUERY_STATE
private static final String SCROLL_ID_STATE
private static final String FIELD_INCLUDE_QUERY_PARAM
private static final String QUERY_QUERY_PARAM
private static final String SORT_QUERY_PARAM
private static final String SCROLL_QUERY_PARAM
private static final String SCROLL_ID_QUERY_PARAM
private static final String SIZE_QUERY_PARAM
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
public static final PropertyDescriptor QUERY
public static final PropertyDescriptor SCROLL_DURATION
public static final PropertyDescriptor INDEX
public static final PropertyDescriptor TYPE
public static final PropertyDescriptor FIELDS
public static final PropertyDescriptor SORT
public static final PropertyDescriptor PAGE_SIZE
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic final List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponent@OnScheduled public void setup(ProcessContext context)
setup in class AbstractElasticsearchProcessorpublic void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate void getPage(okhttp3.Response getResponse,
URL url,
ProcessContext context,
ProcessSession session,
FlowFile flowFile,
ComponentLog logger,
long startNanos)
throws IOException
IOExceptionprivate boolean isQueryFinished(StateManager stateManager) throws IOException
IOExceptionprivate String loadScrollId(StateManager stateManager) throws IOException
IOExceptionprivate void finishQuery(StateManager stateManager) throws IOException
IOExceptionprivate void saveScrollId(StateManager stateManager, String scrollId) throws IOException
IOExceptionCopyright © 2017 Apache NiFi Project. All rights reserved.