lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntsrikanth <ntsrika...@gmail.com>
Subject XPath value passed to SQL query
Date Mon, 19 Sep 2011 14:10:53 GMT
Hi, 

After little struggle figured out a way of joining xml files with database.
But for some reason it is not working. After the import, only the content
from xml is present in my index. Msql contents are missing. 

To debug, I replaced the parametrized query with a simple select statement
and it worked well. As a next step, I purposefully created a syntax error in
the sql and tried again. This time the import failed as expected printing
the values in the log file. 

What I found interesting is all the values eg. brochure_id are substituted
in the query by a enclosing square brackets. for example:  

SELECT * FROM accommodation_attribute_content where accommodation_code =
'[7850]' and brochure_year = [12] and brochure_id = '[55]'


I have the following in the schema.xml 
    <field indexed="true" multiValued="true" name="c_brochure_id"
omitNorms="false" omitTermFreqAndPositions="false" stored="true"
termVectors="false" type="int"/>
    613    <field indexed="true" multiValued="true" name="c_brochure_year"
omitNorms="false" omitTermFreqAndPositions="false" stored="true"
termVectors="false" type="int"/>
    614    <field indexed="true" multiValued="true"
name="c_accommodation_code" omitNorms="false"
omitTermFreqAndPositions="false" stored="true" termVectors="false"
type="int"/>


And my data configuration: 


dataconfig.xml 
---------------------- 
<?xml version="1.0" encoding="UTF-8"?> 
<dataConfig>
     <dataSource name="mysqlDS" batchSize="-1" convertType="true"
driver="com.mysql.jdbc.Driver" password="stage"
url="jdbc:mysql://x.x.x.x:3306/stagedb?useOldAliasMetadataBehavior=true"
user="dev_stage" />

    <dataSource type="FileDataSource" />
    <document>
        <entity name="f" processor="FileListEntityProcessor"
baseDir="/root/csvs/sample/output" fileName=".*xml" newerThan="'NOW-5DAYS'"
recursive="true" rootEntity="false" dataSource="null">
            <entity name="x" processor="XPathEntityProcessor"
forEach="/packages/record" url="${f.fileAbsolutePath}" stream="true"
logLevel="debug">
               <field column="id" xpath="/packages/record/id" />
               <field column="c_brochure_id"
xpath="/packages/record/brochure_id" />
               <field column="c_brochure_year"
xpath="/packages/record/brochure_year" />
               <field column="c_accommodation_code"
xpath="/packages/record/accommodation_code" />

               <entity name="accommodationAttribute" query="SELECT * FROM
accommodation_attribute_content where accommodation_code =
'${x.c_accommodation_code}' and brochure_year = ${x.c_brochure_year} and
brochure_id = '${x.c_brochure_id}'" dataSource="mysqlDS">

                    </entity>
            </entity>
        </entity>
    </document>
</dataConfig>


Any idea why I am getting this weird substitution ? 

Thanks, 
Srikanth 

--
View this message in context: http://lucene.472066.n3.nabble.com/XPath-value-passed-to-SQL-query-tp3348658p3348658.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message