Hi,
I have a classbridge that creates a number of custom fields (not present in the class) that require a particular analyzer to be applied to them.
However, it seems that the correct analyzer is not being applied. Stepping through the code, I see that Classbridge analyzers are being added as scoped analyzers applied to an empty field name.
I'm wondering if this is why my analyzer is not being applied. In Luke I see what looks like a standardAnalyzer like result. Any ideas why?
BTW, manually creating the analyzer withing the fieldbridge and applying it as a tokenstream resolves the issue, so it would seem like a bug.
Code:
@Entity
@Table
@AnalyzerDefs({
@AnalyzerDef(name = "autocompleteAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class, params = {
@Parameter(name="words", value= "nl/project/dao/hibernate/search/stopwords/stopwords-combined.txt" ),
@Parameter(name="ignoreCase", value="true")
}),
@TokenFilterDef(factory = ASCIIFoldingFilterFactory.class),
@TokenFilterDef(factory = EdgeNGramFilterFactory.class, params = {
@org.hibernate.search.annotations.Parameter(name = "minGramSize", value = "2"),
@org.hibernate.search.annotations.Parameter(name = "maxGramSize", value = "15")
})
}),
@AnalyzerDef(name = "mlAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = StandardFilterFactory.class),
@TokenFilterDef(factory = ASCIIFoldingFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class)
})
})
@ClassBridges({
@ClassBridge(
impl=MultiLingualClassBridge.class,
store=Store.YES,
params={
@Parameter(name="field",value="tag"),
@Parameter(name="useAnalyzer",value="true")
}
),
@ClassBridge(
impl=MultiLingualClassBridge.class,
store=Store.NO,
analyzer=@Analyzer(definition="autocompleteAnalyzer"),
params=@Parameter(name="field",value="tag_kw")
)
})
@Indexed
public class Tag implements Serializable{
[...]
public class MultiLingualClassBridge implements FieldBridge,ParameterizedBridge {
@Override
public void set(
String name,
Object value,
Document document,
LuceneOptions luceneOptions) {
field = new Field("myCustom_en", myValue,luceneOptions.getStore(), Index.ANALYZED);