加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

如何在SOLR中编制.html文件索引

发布时间:2020-12-14 23:21:46 所属栏目:资源 来源:网络整理
导读:我想要做索引的文件存储在服务器上(我不需要抓取). /路径/到/文件/ 示例 HTML文件是 meta http-equiv="Content-Type" content="text/html; charset=UTF-8"meta name="product_id" content="11"/meta name="assetid" content="10001"/meta name="title" conte
我想要做索引的文件存储在服务器上(我不需要抓取). /路径/到/文件/
示例 HTML文件是
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="product_id" content="11"/>
<meta name="assetid" content="10001"/>
<meta name="title" content="title of the article"/>
<meta name="type" content="0xyzb"/>
<meta name="category" content="article category"/>
<meta name="first" content="details of the article"/>

<h4>title of the article</h4>
<p class="link"><a href="#link">How cite the Article</a></p>
<p class="list">
  <span class="listterm">Length: </span>13 to 15 feet<br>
  <span class="listterm">Height to Top of Head: </span>up to 18 feet<br>
  <span class="listterm">Weight: </span>1,200 to 4,300 pounds<br>
  <span class="listterm">Diet: </span>leaves and branches of trees<br>
  <span class="listterm">Number of Young: </span>1<br>
  <span class="listterm">Home: </span>Sahara<br>

</p>
</p>

我在solrconfing.xml文件中添加了请求处理程序.

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
  <str name="config">/path/to/data-config.xml</str>
</lst>

我的data-config.xml看起来像这样

<dataConfig>
<dataSource type="FileDataSource" />
<document>
    <entity name="f" processor="FileListEntityProcessor" baseDir="/path/to html/files/" fileName=".*html" recursive="true" rootEntity="false" dataSource="null">
        <field column="plainText" name="text"/>
    </entity>
</document>
</dataConfig>

我保留了默认的schema.xml文件,并将以下代码添加到schema.xml文件中.

<field name="product_id" type="string" indexed="true" stored="true"/>
 <field name="assetid" type="string" indexed="true" stored="true" required="true" />
 <field name="title" type="string" indexed="true" stored="true"/>
 <field name="type" type="string" indexed="true" stored="true"/>
 <field name="category" type="string" indexed="true" stored="true"/>
 <field name="first" type="text_general" indexed="true" stored="true"/>

 <uniqueKey>assetid</uniqueKey>

当我在设置它之后尝试进行完全导入时,它显示所有html文件都已获取.但是当我在SOLR中搜索时,它没有向我显示任何结果.任何人都知道可能的原因是什么?

我的理解是所有文件都正确获取但未在SOLR中编入索引.有谁知道如何在SOLR中索引那些元标记和HTML文件的内容?

您的回复将不胜感激.

解决方法

您可以使用 Solr Extracting Request Handler将Solr与HTML文件一起提供,并从html文件中提取内容.例如在 link

Solr使用Apache Tika从uploaded html file中提取内容

如果你想抓取网站并将其编入索引,Nutch与Solr是一个更广泛的解决方案.
Nutch with Solr Tutorial将帮助您入门.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读