开发者

Solr analyzer - use file

开发者 https://www.devze.com 2023-01-27 22:27 出处:网络
I am writing my own analyzer, and i need to use a file with rules in it. I need this file to be configurable in schema. I wrote such code to get this file:

I am writing my own analyzer, and i need to use a file with rules in it. I need this file to be configurable in schema. I wrote such code to get this file:

String fileName 开发者_高级运维= args.get("file");
File file = new File(fileName);

This code gets searches file in directory, where solr.home is. In my case it is "example" directory. But i need to search it in cores conf directory. How can i specify to look it in that directory?


Ok, for everyone, who will need such functionality:

  1. Implement ResourceLoader.
  2. Add unimplemented method inform(ResourceLoader).
  3. Get lines from file using method resourceLoader.getLines(String filePath). File must be stored in conf directory.
  4. Put lines as local variable, because inform method is called, when solr starts.
  5. Pass lines to filter when needed.

That`s all!

0

精彩评论

暂无评论...
验证码 换一张
取 消