如何为 solr DataImportHandler 创建自定义 Transformer?
我正在尝试使用数据导入处理程序从数据库读取数据后对其进行索引,但我需要在将数据索引到 solr 之前处理数据...为此,我正在尝试创建自定义转换器,但我无法这样做... ..我已经编写了 http://wiki.apache.org/solr/DIHCustomTransformer< 上给出的java代码/a>...但他们没有给出指示关于如何使用它...... PS>我对 java 很陌生,
即使执行了此处提到的所有三种方法,我也无法加载变压器 http://wiki.apache.org/solr/SolrPlugins#How_to_Load_Plugins...
在我的data-config.xml中我添加了一个实体:
<entity name="cod" query=".. " transformer="foo.check">
</entity>
java代码:
package foo;
import java.util.*;
public class check {
...
...
}
然后我已经使用命令制作了jar文件 “jar cvf foo.jar check.class” 并在 solr 中创建 lib 目录后将 foo.jar 放入 example/solr/lib 中......我也尝试了其他两种方法...
即在 solrconfig.xml 中指定 lib 路径并在 solr.war 中添加 foo.jar
I am trying to index data after reading it from database using Data Import Handler but I need to process the data before indexing it to solr... for that I am trying to create custom transformers but I am not able to do so..... I have written the java code as given on http://wiki.apache.org/solr/DIHCustomTransformer... but they have not given instructions on how to use it....
P.S.> I am quite new to java
i'm not able to load the transformer even after performing all three ways mentioned here http://wiki.apache.org/solr/SolrPlugins#How_to_Load_Plugins...
in my data-config.xml i've added an entity:
<entity name="cod" query=".. " transformer="foo.check">
</entity>
java code:
package foo;
import java.util.*;
public class check {
...
...
}
Then I have made jar file using command
"jar cvf foo.jar check.class"
and placed foo.jar inside example/solr/lib after making lib directory inside solr..... I have tried other two methods as well...
i.e. specify lib path inside solrconfig.xml and add foo.jar inside solr.war
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您指的是如何包含 Solr 的类来使用它,请检查 http://wiki .apache.org/solr/SolrPlugins#How_to_Load_Plugins
您可以将类打包为 jar 并将其添加到 solr core 的 lib 文件夹中,这样Solr 可以加载您构建的自定义插件类。
对于配置中类的引用 -
用法如 URL 中定义。
您需要在 data-config.xml 中指定具有完整包名称的转换器,如下所示:
If you are referring to how to include the class for Solr to use it, please check http://wiki.apache.org/solr/SolrPlugins#How_to_Load_Plugins
You can package the class as a jar and add it to the lib folder of your solr core, so that Solr can load the custom plugin classes you have built.
For the reference of the class in the configuration -
The usage is as defined in the URL.
You will need to specify the transformer with the full package name in your data-config.xml as follows:
这可能与您创建 jar 文件的方式有关。解压 jar 文件,您应该找到一个名为“foo”的文件夹,并且在该文件夹内应该有 check.class(foo/check.class)。我有一种感觉,您只是将 check.class 文件放入其中,然后使用“foo.check”引用它。检查这一点的另一种方法是将变压器更改为仅“检查”,因此“transformer =“check””。 jar 文件中的文件夹层次结构和完全限定的类名需要完全匹配。
This might be related to how you create your jar file. Unpack the jar file and you should find a folder called "foo" and inside this folder there should be check.class, (foo/check.class). I have a feeling you are only putting the check.class file in it and then referencing it using "foo.check". Another way you can check this is to change transformer to just "check", so 'transformer="check"'. The folder hierarchy in the jar file and the fully qualified class name need to exactly match.