Hello all,
I'm new to solr and I'm having a hard time trying to configure the
schema.xml for a simple table.
I'm using WebLogic with standard configs and Oracle Database. I have a
simple table with the following fields
Fase varchar
Campo varchar
Antes varchar
Depois varchar
Regras varchar
My schema.xml is like this:
<field name="fase" type="text_general" indexed="true" stored="true"/>
<field name="campo" type="text_general" indexed="true" stored="true"/>
<field name="antes" type="text_general" indexed="true" stored="true"/>
<field name="depois" type="text_general" indexed="true" stored="true"/>
<field name="regras" type="text_general" indexed="true" stored="true"/>
My publish class in Java is like that:
package br.com.trateme.solr;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrInputDocument;
public class Publish {
/**
* @param args
*/
public static void main(String[] args) {
String solrUrl = "http://localhost:7001/solr/";
Connection connection = null;
Statement stmt = null;
try {
SolrServer server = new CommonsHttpSolrServer(solrUrl);
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url = "jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS_LIST = (ADDRESS =
(PROTOCOL = TCP)(HOST = 123.0.0.10)(PORT = 1521)))(CONNECT_DATA =
(SERVICE_NAME = OTEX)))";
String username = "teste_solr";
String password = "teste_solr";
connection = DriverManager.getConnection(url, username,
password);
stmt = connection.createStatement();
ResultSet rs = stmt
.executeQuery("select * from trateme");
while (rs.next()) {
String fase = rs.getString("FASE");
String campo = rs.getString("CAMPO");
String antes = rs.getString("ANTES");
String depois = rs.getString("DEPOIS");
String regras = rs.getString("REGRAS");
System.out.println(fase);
System.out.println(campo);
System.out.println(antes);
System.out.println(depois);
System.out.println(regras);
System.out.println("-------");
SolrInputDocument documento = new
SolrInputDocument();
documento.addField("fase", fase);
documento.addField("campo", campo);
documento.addField("antes", antes);
documento.addField("depois", depois);
documento.addField("regras", regras);
UpdateRequest req = new UpdateRequest();
req.setAction(AbstractUpdateRequest.ACTION.COMMIT, false,
false);
req.add(documento);
UpdateResponse rsp = req.process(server);
System.out.println(rsp);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
*StackTrace:*
Bad Request
request:
http://localhost:7001/solr/update?commit=true&waitFlush=false&waitSearcher=false&wt=javabin&version=2
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:432)
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:246)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
at br.com.trateme.solr.Publish.main(Publish.java:69)
I've seen other topics about Bad Request and I really tried to spot my
error, but I'm not finding it. Can anyone point me to the right direction,
please?
Thank you very much to all,
Joao
--
View this message in context:
http://lucene.472066.n3.nabble.com/Bad-Request-Solr-Weblogic-Oracle-DB-tp3709763p3709763.html
Sent from the Solr - User mailing list archive at Nabble.com.