如何在ApacheSolr中获取索引Word文档的文件名?

如何在ApacheSolr中获取索引Word文档的文件名?,solr,lucene,indexing,solr4,Solr,Lucene,Indexing,Solr4,我曾经使用以下url上传Word文档并为其编制索引 java -Durl=http://localhost:8983/solr/update/extract?literal.id=1 -Dtype=application/word -jar post.jar microfost_det.doc 当我查询Solr索引时,它将XML返回为 http://localhost:8983/solr/collection1/select?q=microfost&wt=xml&inden

我曾经使用以下url上传Word文档并为其编制索引

java -Durl=http://localhost:8983/solr/update/extract?literal.id=1 -Dtype=application/word -jar post.jar microfost_det.doc
当我查询Solr索引时,它将XML返回为

  http://localhost:8983/solr/collection1/select?q=microfost&wt=xml&indent=true
答复是:

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="indent">true</str>
<str name="q">microfost</str>
<str name="_">1389196238897</str>
<str name="wt">xml</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="id">1</str>
<date name="last_modified">1601-01-01T00:00:00Z</date>
<str name="author">fazlan </str>
<str name="author_s">fazlan </str>
<arr name="content_type">
<str>application/msword</str>
</arr>
<arr name="content">
<str> 


This is a MSWord document. Microfost.

</str>
</arr>
<long name="_version_">1456677821213573120</long></doc>
</result>
</response>

0
0
真的
缩微胶片
1389196238897
xml
1.
1601-01-01T00:00:00Z
法兹兰
法兹兰
应用程序/msword
这是一个MSWord文档。缩微胶片。
1456677821213573120
现在我的问题是,我需要包含查询文本“microfost”的文档的名称,即microfost_det.doc

是否可以获取包含查询文本的Word文件名(即filename.doc)


.

在Solr中,默认的可搜索字段是“内容”。这就是为什么你会得到与内容匹配的结果。首先创建一个自定义字符串字段(例如docname),修改schema.xml

然后重新启动Solr实例。执行以下命令以更新Solr文档

curl 'http://localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","docname":{"set":"microfost_det.doc"}}]'
然后执行下面的查询,您将得到结果

http://localhost:8983/solr/collection1/select?q=docname:microfost*&wt=xml&indent=true
否则,在提取文档时,请执行以下命令

java -Durl="http://localhost:8983/solr/update/extract?literal.id=1&literal.docname=microfost_det.doc" -Dtype=application/word -jar post.jar microfost_det.doc

无论如何,您必须将文档名称存储在单独的字段中。

谢谢。。但我怎样才能说出每一份文件的名字。。。也就是说,我在问题摘要中提到的命令是……*。博士。。既然我有1000多个文档要索引,是否可以给每个文档命名