Thanks gistolero. I have added this to the FAQ http://wiki.apache.org/solr/DataImportHandlerFaq
On Wed, Nov 19, 2008 at 2:34 AM, <[EMAIL PROTECTED]> wrote: > Very cool :-) > > Both suggestions work fine! But only with solr version 1.4: > https://issues.apache.org/jira/browse/SOLR-823 > > Use a nightly build (e.g. 2008-11-17 works): > http://people.apache.org/builds/lucene/solr/nightly/ > > See below for examples for both solutions... > > > > ((( 1 ))) > >> There may be one way to do this. >> >> Add your property in the invariant section of solrconfig's >> DataImportHandler >> element. For example, add this section: >> >> <lst name="invariants"> >> <str name="xmlDataDir">${xmlDataDir}</str> >> </lst> >> >> Then you can use it as ${dataimporter.request.xmlDataDir} in your >> data-config to access this. > > > > // *** solr.xml *** > <solr persistent="false"> > <cores adminPath='null'> > <core name="core1" instanceDir="/opt/solr/cores/core1"> > <property name="xmlDataDir" value="/home/core1" /> > </core> > <core name="core2" instanceDir="/opt/solr/cores/core2"> > <property name="xmlDataDir" value="/home/core2" /> > </core> > </cores> > </solr> > > > > // *** solrconfig.xml *** > <requestHandler name="/dataimport" > class="org.apache.solr.handler.dataimport.DataImportHandler"> > <lst name="defaults"> > <str name="config">./data-config.xml</str> > </lst> > > <lst name="invariants"> > <str name="xmlDataDir">${xmlDataDir}</str> > </lst> > </requestHandler> > > > > // *** data-config.xml *** > <dataConfig> > <dataSource type="FileDataSource" /> > <document> > <entity name="xmlFile" > processor="FileListEntityProcessor" > baseDir="${dataimporter.request.xmlDataDir}" > ... > </dataConfig> > > > URL for full-import: > http://localhost:8983/solr/core1/dataimport?command=full-import&commit=true > > > > > ((( 2 )))) > > >> > nope . It is not possible as of now. the placeholders are not aware of >> > the core properties. >> > Is it possible to pass the values as request params? Request >> > parameters can be accessed . > > > // *** data-config.xml *** > <dataConfig> > <dataSource type="FileDataSource" /> > <document> > <entity name="xmlFile" > processor="FileListEntityProcessor" > baseDir="${dataimporter.request.xmlDataDir}" > ... > </dataConfig> > > > URL for full-import: > http://localhost:8983/solr/core1/dataimport?command=full-import&commit=true&xmlDataDir=%2Fhome%2Fcore1 > > > Thats all. > Gisto > > > >> > On Mon, Nov 17, 2008 at 7:57 PM, <[EMAIL PROTECTED]> wrote: >> > > Hello, >> > > >> > > is it possible to use properties from core configuration in >> > data-config.xml? >> > > I want to define the "baseDir" for DataImportHandler. >> > > >> > > >> > > I tried the following configuration: >> > > >> > > >> > > *** solr.xml *** >> > > >> > > <solr persistent="false"> >> > > <cores adminPath='null'> >> > > <core name="core0" instanceDir="/opt/solr/cores/core0"> >> > > <property name="solrDataDir" value="/opt/solr/cores/core0/data" /> >> > > <property name="xmlDataDir" value="/home/xml/core0" /> >> > > </core> >> > > ... >> > > </cores> >> > > </solr> >> > > >> > > >> > > >> > > >> > > *** data-config.xml *** >> > > >> > > <dataConfig> >> > > <dataSource type="FileDataSource" /> >> > > <document> >> > > <entity name="xmlFile" >> > > processor="FileListEntityProcessor" >> > > baseDir="${xmlDataDir}" >> > > fileName="id-.*\.xml" >> > > rootEntity="false" >> > > dataSource="null"> >> > > <entity name="data" >> > > pk="id" >> > > url="${xmlFile.fileAbsolutePath}" >> > > processor="XPathEntityProcessor" >> > > ... >> > > </dataConfig> >> > > >> > > >> > > >> > > But this is the result: >> > > >> > > ... >> > > Nov 17, 2008 1:50:08 PM >> org.apache.solr.handler.dataimport.DataImporter >> > doFullImport >> > > INFO: Starting Full Import >> > > Nov 17, 2008 1:50:08 PM org.apache.solr.core.SolrCore execute >> > > INFO: [posts-politics] webapp=/solr path=/dataimport >> > >> params={optimize=true&commit=true&command=full-import&qt=/dataimport&wt=javabin&version=2.2} >> > status=0 QTime=66 >> > > Nov 17, 2008 1:50:08 PM org.apache.solr.core.SolrCore execute >> > > INFO: [posts-politics] webapp=/solr path=/dataimport >> > params={qt=/dataimport&wt=javabin&version=2.2} status=0 QTime=0 >> > > Nov 17, 2008 1:50:08 PM org.apache.solr.update.DirectUpdateHandler2 >> > deleteAll >> > > INFO: [posts-politics] REMOVING ALL DOCUMENTS FROM INDEX >> > > Nov 17, 2008 1:50:08 PM >> org.apache.solr.handler.dataimport.DataImporter >> > doFullImport >> > > SEVERE: Full Import failed >> > > org.apache.solr.handler.dataimport.DataImportHandlerException: >> 'baseDir' >> > should point to a directory Processing Document # 1 >> > > at >> > >> org.apache.solr.handler.dataimport.FileListEntityProcessor.init(FileListEntityProcessor.java:81) >> > > ... >> > > >> > > >> > > >> > > >> > > I tried also to configure all dataimport settings in solrconfig.xml, >> but >> > I don't know how to do this exactly. Among other things, I tried this >> > format: >> > > >> > > >> > > *** solrconfig.xml *** >> > > >> > > ... >> > > <requestHandler name="/dataimport" >> > class="org.apache.solr.handler.dataimport.DataImportHandler"> >> > > <lst name="defaults"> >> > > <lst name="datasource"> >> > > <str name="type">FileDataSource</str> >> > > <lst name="document"> >> > > <lst name="entity"> >> > > <str name="name">xmlFile</str> >> > > <str name="processor">FileListEntityProcessor</str> >> > > <str name="baseDir">${xmlDataDir}</str> >> > > <str name="fileName">id-.*\.xml</str> >> > > <str name="rootEntity">false</str> >> > > <str name="dataSource">null"</str> >> > > <lst name="entity"> >> > > <str name="name">data</str> >> > > <str name="pk">id</str> >> > > <str name="url">${xmlFile.fileAbsolutePath}</str> >> > > ... >> > > </requestHandler> >> > > ... >> > > >> > > >> > > >> > > But all my tests (with different "dataimport" formats in >> solrconfig.xml) >> > failed: >> > > >> > > >> > > ... >> > > INFO: Reusing parent classloader >> > > Nov 17, 2008 2:18:14 PM org.apache.solr.common.SolrException log >> > > SEVERE: Error in solrconfig.xml:org.apache.solr.common.SolrException: >> No >> > system property or default value specified for xmlFile.fileAbsolutePath >> > > at >> > org.apache.solr.common.util.DOMUtil.substituteProperty(DOMUtil.java:311) >> > > at >> > >> org.apache.solr.common.util.DOMUtil.substituteProperties(DOMUtil.java:264) >> > > ... >> > > >> > > >> > > >> > > Thanks again for your excellent support! >> > > >> > > Gisto >> > > >> > > -- >> > > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! >> > > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer >> > > >> > >> > >> > >> > -- >> > --Noble Paul >> > >> >> >> >> -- >> Regards, >> Shalin Shekhar Mangar. > > -- > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > -- --Noble Paul