I have installed solr-commons package through apt-get (Ubuntu 10.10). I can browse to http://localhost:8080/solr and it works fine.
I have defined a schema like this:
<fields>
<field name="idEmpresa" type="sint" indexed="true" stored="true" required="true" />
<field name="nombre" type="text" indexed="true" stored="true" required="true" />
<field name="sitioWeb" type="text" indexed="true" stored="true" required="false" />
<field name="email" type="text" indexed="true" stored="true" required="false" />
<field name="telefono" type="text" indexed="true" stored="true" required="false" />
</fields>
<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
-->
<uniqueKey>idEmpresa</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>nombre</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
This is my data-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/viajeros2_ut8"
user="user"
password="pwd"
/>
<document>
<entity name="empresa" query="select idEmpresa, nombre, sitioWeb, telefono, direccion from empresas WHERE 1">
</entity>
</document>
</dataConfig>
Finally, this is how I set u开发者_开发知识库p my solrconfig.xml:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">/usr/share/solr/conf/data-config.xml</str>
</lst>
</requestHandler>
When I try http://localhost:8080/solr/dataimport?command=full-import
I get this:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">91</int></lst><lst name="initArgs"><lst name="defaults"><str name="config">/usr/share/solr/conf/data-config.xml</str></lst></lst><str name="command">full-import</str><str name="status">idle</str><str name="importResponse"/><lst name="statusMessages"/><str name="WARNING">This response format is experimental. It is likely to change in the future.</str>
</response>
I can't find any logs or any other information that could help me tackle the issue and, as happened to many, the documentation available isn't very helpful.
Any ideas will be very appreciated. Thanks!
If you've installed solr-tomcat via synaptics / apt, then Ubuntu puts the logs for tomcat (which includes Solr output) in:
/var/log/tomcat6/catalina.out
This will probably contain the error:
org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.mysql.jdbc.Driver Processing Document # 1
...which means that Solr can't find a MySql driver for Java.
So, install a driver:
sudo apt-get install libmysql-java
...and create a symlink to the driver package somewhere Solr can find it:
sudo mkdir /usr/share/solr/lib
cd /usr/share/solr/lib
sudo ln -s /usr/share/java/mysql-connector-java.jar
That seems to have gotten me to a point where I've managed to index a simple table from MySql, hope it helps.
精彩评论