我使用mlcp从一个网络泵送到我的网络的文件不是通过java搜索,而是我从我的计算机上传的文件正在被搜索(即)字符串搜索。上面的内容是通过使用POSTMAN解决但我需要java` / *
中的解决方案public class Example_16_SearchString {
public static void main(String[] args) throws IOException {
// create the client
DatabaseClient client =
DatabaseClientFactory.newClient(Config.host, Config.port,
Config.user, Config.password, Config.authType);
// create a manager for searching
QueryManager queryMgr = client.newQueryManager();
// create a search definition
StringQueryDefinition query = queryMgr.newStringDefinition();
query.setCriteria("189638");
// create a handle for the search results
SearchHandle resultsHandle = new SearchHandle();
// run the search
queryMgr.search(query, resultsHandle);
// Format the results
TutorialUtil.displayResults(resultsHandle);
// release the client
client.release();
}
}
public class TutorialUtil {
public static void displayResultURIs(SearchHandle resultsHandle) {
// Get the list of matching documents in this page of results
MatchDocumentSummary[] results = resultsHandle.getMatchResults();
System.out.println("Listing " + results.length + " documents:");
// List the URI of each matching document
for (MatchDocumentSummary result : results) {
System.out.println(result.getUri());
}
}
public static void displayJSONResultDocs(
SearchHandle resultsHandle, DatabaseClient client)
{
JSONDocumentManager mgr = client.newJSONDocumentManager();
// iterate over the result documents
MatchDocumentSummary[] results = resultsHandle.getMatchResults();
System.out.println("Listing " + results.length + " documents:\n");
for (MatchDocumentSummary result : results) {
StringHandle content = new StringHandle();
mgr.read(result.getUri(), content);
System.out.println(content.get());
}
}
public static void displayResults(SearchHandle resultsHandle) {
System.out.println("Matched " + resultsHandle.getTotalResults() + " documents\n");
// Get the list of matching documents in this page of results
MatchDocumentSummary[] results = resultsHandle.getMatchResults();
System.out.println("Listing " + results.length + " documents:\n");
// Iterate over the results
for (MatchDocumentSummary result : results) {
// get the list of match locations for this result
MatchLocation[] locations = result.getMatchLocations();
System.out.println("Matched " + locations.length + " locations in " + result.getUri() + ":");
// iterate over the match locations
for (MatchLocation location : locations) {
// iterate over the snippets at a match location
for (MatchSnippet snippet : location.getSnippets()) {
boolean isHighlighted = snippet.isHighlighted();
if (isHighlighted)
System.out.print("[");
System.out.print(snippet.getText());
if (isHighlighted)
System.out.print("]");
}
System.out.println();
}
System.out.println();
}
}
}