我正在为我们的电子商务搜索功能实现solr,我在jboss中运行solr.war,solr home位于不同的目录路径中。我已经配置了我的db-data-config.xml来映射mysql数据库
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/employees"
user="root"
password="admin" />
<document name="ecomm">
<entity name="employees" query="select emp_no, first_name, last_name from employees limit 2000">
<field name="emp_no" column="EMP_NO" />
<field name="first_name" column="FIRST_NAME" />
<field name="last_name" column="LAST_NAME" />
</entity>
</document>
</dataConfig>
当我执行完全导入时,所有2000条记录都会被导入,但它没有被编入索引。所以当我查询它时
Requests: 1 (1/s), Fetched: 2,000 (2,000/s), Skipped: 0, Processed: 0 (0/s)
http://localhost:8080/solr/employees/select?q=*%3A*&wt=json&indent=true
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"indent":"true",
"q":"*:*",
"wt":"json"}},
"response":{"numFound":0,"start":0,"docs":[]
}}
当我调整查询并添加别名“id”时,id正在获取processed
,即已编入索引
Requests: 1, Fetched: 2,000, Skipped: 0, Processed: 2,000
query="select emp_no as 'id', first_name , last_name from employees limit 2000"
在查询时只获取'id'数据。
"response": {
"numFound": 2000,
"start": 0,
"docs": [
{
"id": "10001",
"_version_": 1501167564520161300
},
编辑: - 添加数据库架构屏幕截图