为什么 Tika 门面选择 EmptyParser? [英] Why does the Tika facade choose EmptyParser?
本文介绍了为什么 Tika 门面选择 EmptyParser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Tika 外观,根据 elasticsearch-mappper-attachment 插件.这是我的测试代码:
I'm using the Tika facade, per the example of the elasticsearch-mappper-attachment plugin. Here's my test code:
Tika tika = new Tika();
Metadata md = new Metadata();
try {
String content = tika.parseToString(src, md, 100000);
System.out.println("Content length: " + content.length());
for (String s: md.names()) {
System.out.println(s + ": " + md.get(s));
}
}
catch (TikaException e) {
System.out.println(e);
}
输出如下:
Content length: 0
X-Parsed-By: org.apache.tika.parser.EmptyParser
Content-Type: text/html
所以问题是:如果 Tika 正确地将输入识别为 text/html
,为什么它使用 EmptyParser
?如果我应该传递一个解析器,我应该传递哪个解析器以获得最佳结果,假设自动检测成功,如上所述.
So the question is: if Tika correctly identifies the input as text/html
, why does it use the EmptyParser
? If I'm supposed to pass a parser, which parser should I pass for best results, assuming that autodetection is successful, as above.
谢谢.
推荐答案
确保 tika-parsers
在您的类路径中!如果您使用的是 Gradle,
Make sure that tika-parsers
is on your classpath! If you are using Gradle,
compile 'org.apache.tika:tika-parsers:1.7'
会解决问题.
这篇关于为什么 Tika 门面选择 EmptyParser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文