mirror of https://github.com/apache/lucene.git
SOLR-14130: Get working with branch_8x
This commit is contained in:
parent
f35cd71427
commit
861bdae964
|
@ -39,17 +39,17 @@ public class SolrLogPostTool {
|
|||
public static void main(String[] args) throws Exception {
|
||||
|
||||
if(args.length != 2) {
|
||||
CLIO.out("");
|
||||
CLIO.out("postlogs is a simple tool for indexing Solr logs.");
|
||||
CLIO.out("");
|
||||
CLIO.out("parameters:");
|
||||
CLIO.out("");
|
||||
CLIO.out("-- baseUrl: Example http://localhost:8983/solr/collection1");
|
||||
CLIO.out("-- rootDir: All files found at or below the root will be indexed.");
|
||||
CLIO.out("");
|
||||
CLIO.out("Sample syntax 1: ./bin/postlogs http://localhost:8983/solr/collection1 /user/foo/logs/solr.log");
|
||||
CLIO.out("Sample syntax 2: ./bin/postlogs http://localhost:8983/solr/collection1 /user/foo/logs");
|
||||
CLIO.out("");
|
||||
System.out.println("");
|
||||
System.out.println("postlogs is a simple tool for indexing Solr logs.");
|
||||
System.out.println("");
|
||||
System.out.println("parameters:");
|
||||
System.out.println("");
|
||||
System.out.println("-- baseUrl: Example http://localhost:8983/solr/collection1");
|
||||
System.out.println("-- rootDir: All files found at or below the root will be indexed.");
|
||||
System.out.println("");
|
||||
System.out.println("Sample syntax 1: ./bin/postlogs http://localhost:8983/solr/collection1 /user/foo/logs/solr.log");
|
||||
System.out.println("Sample syntax 2: ./bin/postlogs http://localhost:8983/solr/collection1 /user/foo/logs");
|
||||
System.out.println("");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ public class SolrLogPostTool {
|
|||
try {
|
||||
doc = recordReader.readRecord();
|
||||
} catch (Throwable t) {
|
||||
CLIO.err("Error reading log record:"+ bufferedReader.getLineNumber() +" from file:"+ fileName);
|
||||
CLIO.err(t.getMessage());
|
||||
System.err.println("Error reading log record:"+ bufferedReader.getLineNumber() +" from file:"+ fileName);
|
||||
System.err.println(t.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,9 @@ public class SolrLogPostTool {
|
|||
doc.addField("file_s", fileName);
|
||||
request.add(doc);
|
||||
if (rec == 300) {
|
||||
CLIO.out("Sending batch of 300 log records...");
|
||||
System.out.println("Sending batch of 300 log records...");
|
||||
request.process(client);
|
||||
CLIO.out("Batch sent");
|
||||
System.out.println("Batch sent");
|
||||
request = new UpdateRequest();
|
||||
rec = 0;
|
||||
}
|
||||
|
@ -108,10 +108,10 @@ public class SolrLogPostTool {
|
|||
|
||||
if (rec > 0) {
|
||||
//Process last batch
|
||||
CLIO.out("Sending last batch ...");
|
||||
System.out.println("Sending last batch ...");
|
||||
request.process(client);
|
||||
client.commit();
|
||||
CLIO.out("Committed");
|
||||
System.out.println("Committed");
|
||||
}
|
||||
} finally {
|
||||
client.close();
|
||||
|
@ -270,7 +270,7 @@ public class SolrLogPostTool {
|
|||
return doc;
|
||||
}
|
||||
|
||||
private SolrInputDocument parseQueryRecord(String line) {
|
||||
private SolrInputDocument parseQueryRecord(String line) throws IOException {
|
||||
|
||||
SolrInputDocument doc = new SolrInputDocument();
|
||||
doc.addField("date_dt", parseDate(line));
|
||||
|
@ -460,39 +460,43 @@ public class SolrLogPostTool {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
private void addParams(SolrInputDocument doc, String params) {
|
||||
private void addParams(SolrInputDocument doc, String params) throws IOException {
|
||||
String[] pairs = params.split("&");
|
||||
for(String pair : pairs) {
|
||||
String[] parts = pair.split("=");
|
||||
if(parts.length == 2 && parts[0].equals("q")) {
|
||||
String dq = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
String dq = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("q_s", dq);
|
||||
doc.addField("q_t", dq);
|
||||
}
|
||||
|
||||
if(parts[0].equals("rows")) {
|
||||
String dr = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
doc.addField("rows_i", dr);
|
||||
}
|
||||
try {
|
||||
if (parts[0].equals("rows")) {
|
||||
String dr = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("rows_i", dr);
|
||||
}
|
||||
|
||||
if(parts[0].equals("distrib")) {
|
||||
String dr = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
doc.addField("distrib_s", dr);
|
||||
}
|
||||
if (parts[0].equals("distrib")) {
|
||||
String dr = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("distrib_s", dr);
|
||||
}
|
||||
|
||||
if(parts[0].equals("isShard")) {
|
||||
String dr = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
doc.addField("isShard_s", dr);
|
||||
}
|
||||
if (parts[0].equals("isShard")) {
|
||||
String dr = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("isShard_s", dr);
|
||||
}
|
||||
|
||||
if(parts[0].equals("wt")) {
|
||||
String dr = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
doc.addField("wt_s", dr);
|
||||
}
|
||||
if (parts[0].equals("wt")) {
|
||||
String dr = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("wt_s", dr);
|
||||
}
|
||||
|
||||
if(parts[0].equals("facet")) {
|
||||
String dr = URLDecoder.decode(parts[1], Charset.defaultCharset());
|
||||
doc.addField("facet_s", dr);
|
||||
if (parts[0].equals("facet")) {
|
||||
String dr = URLDecoder.decode(parts[1], "UTF-8");
|
||||
doc.addField("facet_s", dr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue