http://wiki.apache.org/solr/ExtractingRequestHandler没有提供太多信息,如何在具有自己的上下文并希望将 solr 用作嵌入 solr 的服务器功能的 web 应用程序中配置此处理程序。您能否提供一些有关如何将文档上传到 solr 并从这些文档中搜索某些内容的信息?我在 solrConf.xml 中配置了 DIH
<requestHandler name="/dataimport"
class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">tika-data-config.xml</str>
</lst>
</requestHandler>
和 tika-data-config.xml 看起来像
<dataConfig>
<dataSource type="BinFileDataSource" name="bin" />
<document>
<entity name="sd"
processor="FileListEntityProcessor"
newerThan="'NOW-30DAYS'"
filenName=".*\.(DOC)|(PDF)|(pdf)|(doc)|(docx)|(ppt)"
baseDir="G:/workspace/FacetedSearch/src/solr/docs"
recursive="true"
rootEntity="false"
>
<field column="fileAbsolutePath" name="path" />
<field column="fileSize" name="size" />
<field column="fileLastModified" name="lastmodified" />
<field column="fileAbsolutePath" name="text" />
<!-- <field column="fileName" name="text" /> -->
<field column="baseDir" name="text" />
<!-- <entity name="tika-test" processor="TikaEntityProcessor"
url="${sd.fileAbsolutePath}" format="text" dataSource="bin">
-->
<entity name="tika-test"
dataSource="bin"
processor="TikaEntityProcessor"
url="G:/workspace/FacetedSearch/src/solr/docs"
format="text" >
<field column="Author" name="author" meta="true"/>
<field column="Content-Type" name="title" meta="true"/>
<field column="title" name="title" meta="true"/>
<field column="text" name="text"/>
</entity>
</entity>
</document>
</dataConfig>
目录 G:/workspace/FacetedSearch/src/solr/docs 包含许多 pdf 和 html 文件,其中一些是 tutorial.pdf......index.pdf
在此配置之后,当我将 solrQuery 对象构建为
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();
EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");
SolrQuery solrQuery = new SolrQuery();
solrQuery.addField("literal.id");
solrQuery.setQuery("index.pdf");
QueryResponse queryResponse = null ;
try{
queryResponse = (QueryResponse) solrServer.query(solrQuery);
}catch(Exception e){
System.out.println("exception occured while processing the solrQuery "+
e.getMessage() +"stack trace " + e + solrQuery.toString());
}
out.println(queryResponse);
我没有得到任何结果(这里 queryResponse 为空)。我有 solr 3.5 分发的 schema.xml 并添加了一些字段作为
<field name="path" type="text_general" indexed="true" stored="true" />
<field name="lastmodified" type="date" indexed="true" stored="true" />
我有一个问题,比如“G:/workspace/FacetedSearch/src/solr/docs”中的文档是否会在 solr 启动时被 solr 索引?如果这些被索引,我怎样才能得到结果?
任何人都可以让我知道我在哪里做错了吗?
如果需要我提供更多信息以获取我的答案,请告诉我。