I tried the following SQL in entity tag of dataimport config file:
<entity name="Page" dataSource="a1" query="SELECT &apos;26484-&apos;&amp;`book`.id&amp;&apos;-&apos;&amp;`book`.page&amp;&apos;-&apos;&amp;`book`.part AS PageID, `book`.id AS pid, `book`.nass AS Content, `book`.part AS Part, `book`.page AS PageNum FROM `book` ORDER BY `book`.id, `book`.page">
The Sql query contains characters should be escaped in xml, ' and &
. However, I recive the following error in the log:
DocBuilder Exception while processing: Page document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT '26484-'&`book`.id&'-'&`book`.page&'-'&`book`.part AS PageID, `book`.id AS pid, `book`.nass AS Content, `book`.part AS Part, `book`.page AS PageNum FROM `book` ORDER BY `book`.id, `book`.page Processing Document # 1
and
DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT '26484-'&`book`.id&'-'&`book`.page&'-'&`book`.part AS PageID, `book`.id AS pid, `book`.nass AS Content, `book`.part AS Part, `book`.page AS PageNum FROM `book` ORDER BY `book`.id, `book`.page Processing Document # 1
I use ucanaccess jdbc driver.
When I tried to remove concatination from the SQL query so, removing the escaped characters, I have not got this error, but I have got solrWriter warning about duplicate Unique key. and I understand this warning. However, How could I able to write use the Sql query shown above?
There is no need to escape single quotes, you can put '
directly into the query.
A &
is required for every escaped character. So you will need to replace &apos;
with &'
.
The fact that corrupts your query should be (2).
<entity name="Page" dataSource="a1" query="SELECT &'26484-&'&&`book`.id&&&'-&'&&`book`.page&&&'-&'&&`book`.part AS PageID, `book`.id AS pid, `book`.nass AS Content, `book`.part AS Part, `book`.page AS PageNum FROM `book` ORDER BY `book`.id, `book`.page">