-
Notifications
You must be signed in to change notification settings - Fork 25.6k
POC: Cross-Project Search #131168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: Cross-Project Search #131168
Changes from 33 commits
980723e
4ff5e6e
3df7a1d
c21a0a9
5266376
650dd77
9d63d77
8eec08e
fe6b696
8dee748
f9d6407
be2ab99
710d789
3587e6a
26a49c0
2a45f5b
9d29d4f
0ef2258
88104ce
035ffc1
f5cad57
fe3dea0
1153dfa
3fd532e
512222e
b867e69
08d3e4e
d36c3f6
d20a8c9
32ed394
67f5cdf
e25d8b2
137195f
ee93568
18d6bcb
2ae90af
2b092fb
d834784
7de6de0
9e53cc3
2d8a118
01ad89b
4cc41c3
254977c
e427303
efbd82e
d8103f9
1d3dc40
c03c73a
1f04a53
9f341be
7c6b1fc
91bf747
266a822
bf307e2
768affc
d1bd040
a78010b
ca5b153
aaab227
1967bfa
700af92
652caf3
3a8c4dc
24b9f7c
804069c
a61ad84
ab675dc
b11d30a
cd6511f
da74cb5
5373143
6544589
7b7aa7d
2af9134
c17b5c5
7d9a438
80bd89e
0a4046c
49814b1
01276d5
d1bb772
d5af5bc
f380e82
fd1df71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch; | ||
|
||
import org.elasticsearch.action.IndicesRequest; | ||
import org.elasticsearch.core.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public interface CrossProjectAwareRequest extends IndicesRequest { | ||
/** | ||
* Can be used to determine if this should be processed in cross-project mode vs. stateful CCS. | ||
*/ | ||
boolean crossProjectModeEnabled(); | ||
|
||
/** | ||
* Only called if cross-project rewriting (flat-world, linked project filtering) was applied | ||
*/ | ||
void qualified(List<QualifiedExpression> qualifiedExpressions); | ||
|
||
|
||
@Nullable | ||
String queryRouting(); | ||
|
||
/** | ||
* Used to track a mapping from original expression (potentially flat-world) to canonicalized CCS expressions. | ||
* e.g. for an original index expression `logs-*`, this would be: | ||
* original=logs-* | ||
* qualified=[(logs-*, _local), (my-remote:logs-*, my-remote)] | ||
|
||
*/ | ||
record QualifiedExpression(String original, List<ExpressionWithProject> qualified) { | ||
public boolean hasFlatOriginalExpression() { | ||
return true; | ||
} | ||
} | ||
|
||
record ExpressionWithProject(String expression, String project) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
package org.elasticsearch.action.fieldcaps; | ||
|
||
import org.elasticsearch.CrossProjectAwareRequest; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.IndicesRequest; | ||
|
@@ -36,11 +37,16 @@ | |
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public final class FieldCapabilitiesRequest extends LegacyActionRequest implements IndicesRequest.Replaceable, ToXContentObject { | ||
public final class FieldCapabilitiesRequest extends LegacyActionRequest | ||
|
||
implements | ||
CrossProjectAwareRequest, | ||
IndicesRequest.Replaceable, | ||
ToXContentObject { | ||
public static final String NAME = "field_caps_request"; | ||
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.strictExpandOpenAndForbidClosed(); | ||
|
||
|
@@ -58,6 +64,7 @@ public final class FieldCapabilitiesRequest extends LegacyActionRequest implemen | |
private QueryBuilder indexFilter; | ||
private Map<String, Object> runtimeFields = Collections.emptyMap(); | ||
private Long nowInMillis; | ||
private List<QualifiedExpression> qualifiedExpressions; | ||
|
||
|
||
public FieldCapabilitiesRequest(StreamInput in) throws IOException { | ||
super(in); | ||
|
@@ -373,4 +380,25 @@ public String getDescription() { | |
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean crossProjectModeEnabled() { | ||
return qualifiedExpressions != null; | ||
} | ||
|
||
@Override | ||
public void qualified(List<QualifiedExpression> qualifiedExpressions) { | ||
this.qualifiedExpressions = qualifiedExpressions; | ||
indices( | ||
qualifiedExpressions.stream() | ||
.flatMap(indexExpression -> indexExpression.qualified().stream().map(ExpressionWithProject::expression)) | ||
.toArray(String[]::new) | ||
); | ||
} | ||
|
||
@Override | ||
public String queryRouting() { | ||
// TODO how would this look in ES|QL? | ||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security; | ||
|
||
import org.elasticsearch.transport.Transport; | ||
import org.elasticsearch.transport.TransportInterceptor; | ||
import org.elasticsearch.transport.TransportRequest; | ||
import org.elasticsearch.transport.TransportRequestOptions; | ||
import org.elasticsearch.transport.TransportResponse; | ||
import org.elasticsearch.transport.TransportResponseHandler; | ||
|
||
public interface CrossProjectRemoteServerTransportInterceptor { | ||
// TODO probably don't want this | ||
boolean enabled(); | ||
|
||
// TODO this should be a wrapper around TransportInterceptor.AsyncSender instead | ||
<T extends TransportResponse> void sendRequest( | ||
TransportInterceptor.AsyncSender sender, | ||
Transport.Connection connection, | ||
String action, | ||
TransportRequest request, | ||
TransportRequestOptions options, | ||
TransportResponseHandler<T> handler | ||
); | ||
|
||
CustomServerTransportFilter getFilter(); | ||
|
||
class Default implements CrossProjectRemoteServerTransportInterceptor { | ||
@Override | ||
public boolean enabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public <T extends TransportResponse> void sendRequest( | ||
TransportInterceptor.AsyncSender sender, | ||
Transport.Connection connection, | ||
String action, | ||
TransportRequest request, | ||
TransportRequestOptions options, | ||
TransportResponseHandler<T> handler | ||
) { | ||
sender.sendRequest(connection, action, request, options, handler); | ||
} | ||
|
||
@Override | ||
public CustomServerTransportFilter getFilter() { | ||
return new CustomServerTransportFilter.Default(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.transport.TransportRequest; | ||
|
||
public interface CustomServerTransportFilter { | ||
void filter(String securityAction, TransportRequest request, ActionListener<Void> authenticationListener); | ||
|
||
class Default implements CustomServerTransportFilter { | ||
@Override | ||
public void filter(String securityAction, TransportRequest request, ActionListener<Void> listener) { | ||
listener.onResponse(null); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be using this method? The javadoc describes what it does but it's unclear to me which parts needs to know that.