首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

Solr data import 中XML/HTTP 数据源的应用

2012-10-23 
Solrdataimport 中XML/HTTP 数据源的使用dataSource nameb typeHttpDataSource baseUrlhttp://ho

Solr data import 中XML/HTTP 数据源的使用

<dataSource name="b" type="HttpDataSource" baseUrl="http://host:port/" encoding="UTF-8" connectionTimeout="5000" readTimeout="10000"/><!-- or in Solr 1.4--><dataSource name="a" type="URLDataSource" baseUrl="http://host:port/" encoding="UTF-8" connectionTimeout="5000" readTimeout="10000"/>?datasource的属性有:

<dataConfig> <dataSource type="HttpDataSource" /> <document> <entity name="slashdot" pk="link" url="http://rss.slashdot.org/Slashdot/slashdot" processor="XPathEntityProcessor" forEach="/RDF/channel | /RDF/item" transformer="DateFormatTransformer"> <field column="source" xpath="/RDF/channel/title" commonField="true" /> <field column="source-link" xpath="/RDF/channel/link" commonField="true" /> <field column="subject" xpath="/RDF/channel/subject" commonField="true" /> <field column="title" xpath="/RDF/item/title" /> <field column="link" xpath="/RDF/item/link" /> <field column="description" xpath="/RDF/item/description" /> <field column="creator" xpath="/RDF/item/creator" /> <field column="item-subject" xpath="/RDF/item/subject" /> <field column="slash-department" xpath="/RDF/item/department" /> <field column="slash-section" xpath="/RDF/item/section" /> <field column="slash-comments" xpath="/RDF/item/comments" /> <field column="date" xpath="/RDF/item/date" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss" /> </entity> </document></dataConfig>?看到这个东西的确有点迷糊,因此下面是我们索引wikipedia的例子:

<dataConfig> <dataSource type="FileDataSource" encoding="UTF-8" /> <document> <entity name="page" processor="XPathEntityProcessor" stream="true" forEach="/mediawiki/page/" url="/data/enwiki-20100312-pages-articles.xml" transformer="RegexTransformer,DateFormatTransformer" > <field column="id" xpath="/mediawiki/page/id" /> <field column="title" xpath="/mediawiki/page/title" /> <field column="revision" xpath="/mediawiki/page/revision/id" /> <field column="user" xpath="/mediawiki/page/revision/contributor/username" /> <field column="userId" xpath="/mediawiki/page/revision/contributor/id" /> <field column="text" xpath="/mediawiki/page/revision/text" /> <field column="timestamp" xpath="/mediawiki/page/revision/timestamp" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss'Z'" /> <field column="$skipDoc" regex="^#REDIRECT .*" replaceWith="true" sourceColName="text"/> </entity> </document></dataConfig>?注意一下上面的url最好写绝对路径,我的相对路径老是出错-_-。

<field name="id" type="integer" indexed="true" stored="true" required="true"/><field name="title" type="string" indexed="true" stored="false"/><field name="revision" type="sint" indexed="true" stored="true"/><field name="user" type="string" indexed="true" stored="true"/><field name="userId" type="integer" indexed="true" stored="true"/><field name="text" type="text" indexed="true" stored="false"/><field name="timestamp" type="date" indexed="true" stored="true"/><field name="titleText" type="text" indexed="true" stored="true"/>...<uniqueKey>id</uniqueKey><copyField source="title" dest="titleText"/>?下面会花费数小时的时间去索引数据,并且内存使用率将持续最高,请注意很多wikipedia的文章都仅仅是指向其它文章$skipDoc(1.4)的使用可以使得这些文章被忽略,当然前提是正则表达式匹配。

请注意:由于目前唯一支持delta importEntityProcessorSqlEntityProcessor,而XPathEntityProcessor并现在没有实现delta import。如果你想实现这些方法的话,你需要修改EntityProcessor.java?? ? ? ??

热点排行