英文:
Solr Nextcursor mark returning error Unable to parse 'cursorMark' after totem
问题
以下是翻译好的内容:
在我的代码中,我正在尝试搜索页面并获取结果,当我获得返回结果时,我已经将游标标记为*
,当我获得下一个返回游标标记为"AoE/SkhJVkVfRFNDNjAwNDlfVklTVEFfVklTVEFQX1RaX0RCOi8vSGl2ZSBNZXRhc3RvcmUvZHNjNjAwNDlfdmlzdGFfdmlzdGFwX3R6X2RiL2Fucl9sb2dvbl9sb2cvbG9nX3RpbWVzdGFtcA==
时,出现错误:
> 无法解析在 totem 之后的 'cursorMark':值必须是 '*',或者是先前搜索返回的 'nextCursorMark'。
我需要对nextCursorMark
进行编码,以下是我的代码:
do {
String response = RestClient.doGet(url, userName, password, offSetTemp, pageSize, cursorMark);
System.out.println("res:----" + response);
jsonObject = ProfileDataExportUtil.getJson(response);
JsonArray profilingInfo = null;
if (jsonObject.has("items")) {
profilingInfo = jsonObject.get("items").getAsJsonArray();
}
if (profilingInfo == null) continue;
moreResultsExists = profilingInfo.size() >= 1;
ProfileDataExporter.writeProfileInformation(bWriter, profilingInfo);
if (!jsonObject.has("nextCursorMark")) continue;
cursorMark = jsonObject.get("nextCursorMark").toString();
} while (moreResultsExists);
我尝试过使用tostring
,但会引发错误。
我的URL已经编码,当我使用以下代码时:
cursorMark = jsonObject.get("nextCursorMark").getAsString();
我会得到"字符串越界异常"
错误。
有人可以告诉我如何对nextCursorMark
进行编码吗?
英文:
On my code I am trying to search for page and getting result I have included cursor mark as *
when I get the return next cursor mark as "AoE/SkhJVkVfRFNDNjAwNDlfVklTVEFfVklTVEFQX1RaX0RCOi8vSGl2ZSBNZXRhc3RvcmUvZHNjNjAwNDlfdmlzdGFfdmlzdGFwX3R6X2RiL2Fucl9sb2dvbl9sb2cvbG9nX3RpbWVzdGFtcA==
where it's throwing error:
>Unable to parse 'cursorMark' after totem: value must either be '*' or the 'nextCursorMark' returned by a previous search
I need to encode the nextCursorMark
here is my code below:
do {
String response = RestClient.doGet(url, userName, password, offSetTemp, pageSize, cursorMark);
System.out.println("res:----"+response);
jsonObject = ProfileDataExportUtil.getJson(response);
JsonArray profilingInfo = null;
if (jsonObject.has("items")) {
profilingInfo = jsonObject.get("items").getAsJsonArray();
}
if (profilingInfo == null) continue;
moreResultsExists = profilingInfo.size() >= 1;
ProfileDataExporter.writeProfileInformation(bWriter, profilingInfo);
if (!jsonObject.has("nextCursorMark")) continue;
cursorMark = jsonObject.get("nextCursorMark").toString();
} while (moreResultsExists);
I have tried using tostring
which throws an error.
My URL is encoded and when I use
cursorMark = jsonObject.get("nextCursorMark").getAsString();
I get "string out of bound exception"
error.
Can anyone tell me how encode the nextCursorMark
?
答案1
得分: 0
我遇到过类似的问题。这是由于nextCursor的字符串编码造成的。在将其附加到最终URL之前,您也应该对此字符串进行编码。下面是一个示例示例:
from urllib.parse import quote_plus
...
cursorMark = quote_plus(response['nextCursorMark'])
...
英文:
I have faced similar issue. It was due to nextCursor String encoding. You should encode this string also before appending in the final URL. A sample example is given below
from urllib.parse import quote_plus
...
cursorMark = quote_plus(response['nextCursorMark'])
...
专注分享java语言的经验与见解,让所有开发者获益!
评论