org.elasticsearch.action.percolate.PercolateResponse Java Examples
The following examples show how to use
org.elasticsearch.action.percolate.PercolateResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearchPercolatorStore.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
public PercolateResponse percolate(String[] indexNames, String documentType, Object tuple) { XContentBuilder docBuilder; try { docBuilder = XContentFactory.jsonBuilder().startObject(); docBuilder.field("doc").startObject(); //This is needed to designate the document docBuilder.field("content", tuple); docBuilder.endObject(); //End of the doc field docBuilder.endObject();//End of the JSON root object return client.preparePercolate().setIndices(indexNames) .setDocumentType(documentType) .setSource(docBuilder) .execute().actionGet(); } catch (IOException e) { DTThrowable.rethrow(e); } return null; }
Example #2
Source File: ElasticSearchPercolatorOperator.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public void process(Object tuple) { PercolateResponse response = store.percolate(new String[] {indexName}, documentType, tuple); outputPort.emit(response); }
Example #3
Source File: PercolateRequestBuilder.java From elasticshell with Apache License 2.0 | 5 votes |
@Override protected XContentBuilder toXContent(PercolateRequest request, PercolateResponse response, XContentBuilder builder) throws IOException { builder.startObject(); builder.field(Fields.OK, true); builder.startArray(Fields.MATCHES); for (String match : response) { builder.value(match); } builder.endArray(); builder.endObject(); return builder; }
Example #4
Source File: PercolatorService.java From Elasticsearch with Apache License 2.0 | 4 votes |
ReduceResult(long count, PercolateResponse.Match[] matches, InternalAggregations reducedAggregations) { this.count = count; this.matches = matches; this.reducedAggregations = reducedAggregations; }
Example #5
Source File: PercolatorService.java From Elasticsearch with Apache License 2.0 | 4 votes |
public PercolateResponse.Match[] matches() { return matches; }
Example #6
Source File: RestPercolateAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
void executePercolate(final PercolateRequest percolateRequest, final RestChannel restChannel, final Client client) { client.percolate(percolateRequest, new RestToXContentListener<PercolateResponse>(restChannel)); }
Example #7
Source File: ElasticSearchPercolateTest.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
/** * */ private void checkPercolateResponse() { ElasticSearchPercolatorOperator oper = new ElasticSearchPercolatorOperator(); oper.hostName = HOST_NAME; oper.port = PORT; oper.indexName = INDEX_NAME; oper.documentType = DOCUMENT_TYPE; oper.setup(null); String[] messages = {"{content:'This will match only with malhar'}", "{content:'This will match only with github'}", "{content:'This will match with both github and malhar'}", "{content:'This will not match with any of them'}" }; String[][] matches = { {MALHAR_TOPIC}, {GITHUB_TOPIC}, {GITHUB_TOPIC, MALHAR_TOPIC}, {} }; CollectorTestSink<PercolateResponse> sink = new CollectorTestSink<PercolateResponse>(); oper.outputPort.setSink((CollectorTestSink)sink); for (String message : messages) { oper.inputPort.process(message); } int i = 0; for (PercolateResponse response : sink.collectedTuples) { List<String> matchIds = new ArrayList<String>(); for (Match match : response.getMatches()) { matchIds.add(match.getId().toString()); } Collections.sort(matchIds); Assert.assertArrayEquals(matchIds.toArray(), matches[i]); i++; } }
Example #8
Source File: PercolateRequestBuilder.java From elasticshell with Apache License 2.0 | 4 votes |
@Override protected ActionFuture<PercolateResponse> doExecute(PercolateRequest request) { return client.percolate(request); }