我尝试根据zip
开发自己的过滤器,但使用 <dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>5.5.0</version>
</dependency>
作为指向https://dzone.com/articles/writing-solr-analysis-filter
我使用的是Solr 5.5,对于开发项目,我添加到了我的pom.xml:
TokenFilterFactory
至于我使用lucene-analyzers 5.5版本的常见原因,原因是我首先尝试使用solr-core 5.5,并且看到我需要的类是依赖lucene-analyzers-common ,版本5.5。
我使用public class MyNameFilterFactory extends TokenFilterFactory {
Map<String, String> args;
protected MyNameFilterFactory(Map<String, String> args) {
super(args);
}
public Map<String, String> getArgs() {
return args;
}
public void init(Map<String, String> args) {
this.args = args;
}
public MyNameFilter create(TokenStream input) {
return new MyNameFilter(input);
}
}
的课程是:
java.lang.ClassNotFoundException: org.apache.lucene.analysis.util.TokenFilterFactory
我将项目打包为胖jar(否则我得到Caused by: java.lang.ClassCastException: class org.apache.lucene.analysis.tr.ApostropheFilterFactory
at java.lang.Class.asSubclass(Class.java:3404)
at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:158)
at org.apache.lucene.analysis.util.AnalysisSPILoader.reload(AnalysisSPILoader.java:85)
at org.apache.lucene.analysis.util.AnalysisSPILoader.<init>(AnalysisSPILoader.java:65)
at org.apache.lucene.analysis.util.AnalysisSPILoader.<init>(AnalysisSPILoader.java:51)
at org.apache.lucene.analysis.util.TokenFilterFactory.<clinit>(TokenFilterFactory.java:31)
)并将其放在solr-5.5.0 / server / lib下
但是现在,在运行Solr时,我得到了一个我不知道如何解决的错误,因为我看到了一个lucene的内部问题:
import AVFoundation
class ViewController: UIViewController {
let audioEngine = AVAudioEngine()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func recordPressed(sender:AnyObject) {
try! startRecording()
}
func startRecording() throws{
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(AVAudioSessionCategoryRecord)
try audioSession.setMode(AVAudioSessionModeMeasurement)
try audioSession.setActive(true, withOptions: .NotifyOthersOnDeactivation)
guard let inputNode = audioEngine.inputNode else { fatalError("Audio engine has no input node") }
let recordingFormat = inputNode.outputFormatForBus(0)
inputNode.installTapOnBus(0, bufferSize: 1024, format: recordingFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in
}
audioEngine.prepare()
try audioEngine.start()
}
}
知道怎么解决吗? 有没有更好的方法为Solr开发自定义过滤器/标记器?