Solr analyzer - use 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:
- Implement ResourceLoader.
- Add unimplemented method inform(ResourceLoader).
- Get lines from file using method resourceLoader.getLines(String filePath). File must be stored in conf directory.
- Put lines as local variable, because inform method is called, when solr starts.
- Pass lines to filter when needed.
That`s all!
精彩评论