encode scroll id with base64 in url safe manner
This commit is contained in:
parent
cfa8c9aa79
commit
8285ffe221
|
@ -163,7 +163,7 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc
|
|||
}
|
||||
}
|
||||
|
||||
private void innerFinishHim() {
|
||||
private void innerFinishHim() throws Exception {
|
||||
sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
|
||||
final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults);
|
||||
String scrollId = null;
|
||||
|
|
|
@ -258,7 +258,7 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA
|
|||
}
|
||||
}
|
||||
|
||||
private void innerFinishHim() {
|
||||
private void innerFinishHim() throws Exception {
|
||||
final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
|
||||
String scrollId = null;
|
||||
if (request.scroll() != null) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public abstract class TransportSearchHelper {
|
|||
return internalRequest;
|
||||
}
|
||||
|
||||
public static String buildScrollId(SearchType searchType, Iterable<? extends SearchPhaseResult> searchPhaseResults) {
|
||||
public static String buildScrollId(SearchType searchType, Iterable<? extends SearchPhaseResult> searchPhaseResults) throws IOException {
|
||||
if (searchType == SearchType.DFS_QUERY_THEN_FETCH || searchType == SearchType.QUERY_THEN_FETCH) {
|
||||
return buildScrollId(ParsedScrollId.QUERY_THEN_FETCH_TYPE, searchPhaseResults);
|
||||
} else if (searchType == SearchType.QUERY_AND_FETCH || searchType == SearchType.DFS_QUERY_AND_FETCH) {
|
||||
|
@ -89,17 +89,17 @@ public abstract class TransportSearchHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static String buildScrollId(String type, Iterable<? extends SearchPhaseResult> searchPhaseResults) {
|
||||
public static String buildScrollId(String type, Iterable<? extends SearchPhaseResult> searchPhaseResults) throws IOException {
|
||||
StringBuilder sb = new StringBuilder().append(type).append(';');
|
||||
for (SearchPhaseResult searchPhaseResult : searchPhaseResults) {
|
||||
sb.append(searchPhaseResult.id()).append(':').append(searchPhaseResult.shardTarget().nodeId()).append(';');
|
||||
}
|
||||
return Base64.encodeBytes(Unicode.fromStringAsBytes(sb.toString()));
|
||||
return Base64.encodeBytes(Unicode.fromStringAsBytes(sb.toString()), Base64.URL_SAFE);
|
||||
}
|
||||
|
||||
public static ParsedScrollId parseScrollId(String scrollId) {
|
||||
try {
|
||||
scrollId = Unicode.fromBytes(Base64.decode(scrollId));
|
||||
scrollId = Unicode.fromBytes(Base64.decode(scrollId, Base64.URL_SAFE));
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchIllegalArgumentException("Failed to decode scrollId", e);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TransportSearchQueryAndFetchAction extends TransportSearchTypeActio
|
|||
queryFetchResults.put(result.shardTarget(), result);
|
||||
}
|
||||
|
||||
@Override protected void moveToSecondPhase() {
|
||||
@Override protected void moveToSecondPhase() throws Exception {
|
||||
sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values());
|
||||
final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults);
|
||||
String scrollId = null;
|
||||
|
|
|
@ -171,7 +171,7 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi
|
|||
}
|
||||
}
|
||||
|
||||
private void innerFinishHim() {
|
||||
private void innerFinishHim() throws Exception {
|
||||
InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults);
|
||||
String scrollId = null;
|
||||
if (request.scroll() != null) {
|
||||
|
|
|
@ -353,7 +353,7 @@ public abstract class TransportSearchTypeAction extends BaseAction<SearchRequest
|
|||
|
||||
protected abstract void processFirstPhaseResult(ShardRouting shard, FirstResult result);
|
||||
|
||||
protected abstract void moveToSecondPhase();
|
||||
protected abstract void moveToSecondPhase() throws Exception;
|
||||
|
||||
protected abstract String firstPhaseName();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class Lucene {
|
||||
|
||||
public static Version VERSION = Version.LUCENE_CURRENT;
|
||||
@SuppressWarnings({"deprecation"}) public static Version VERSION = Version.LUCENE_CURRENT;
|
||||
public static Version ANALYZER_VERSION = VERSION;
|
||||
public static Version QUERYPARSER_VERSION = VERSION;
|
||||
|
||||
|
@ -280,6 +280,7 @@ public class Lucene {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static Object readFieldValue(StreamInput in) throws IOException {
|
||||
byte type = in.readByte();
|
||||
if (type == -1) {
|
||||
|
@ -327,6 +328,7 @@ public class Lucene {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static void writeFieldValue(StreamOutput out, Object value) throws IOException {
|
||||
if (value == null) {
|
||||
out.writeByte((byte) -1);
|
||||
|
|
Loading…
Reference in New Issue