将您的网桥更改为多次存储相同的字段,每次都具有整数列表的值 a。因此,假设您的字段名为 myInt,您将存储 myInt = 1、myInt = 10 和 myInt = 15,示例代码:
public class MyBridge implements FieldBridge {
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value instanceof List){
for(Object myInt:(List)value){
Field myIntField = new Field(name, myInt.toString(), luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
myIntField.setBoost(luceneOptions.getBoost());
document.add(myIntField);
}
}
}
}
或者,您可以插入一些自定义的 lucene过滤器来执行此操作,但过滤器有点复杂。