Hi, I have a field name in an entity and name can contain [dot,.] as a seperator between First, Middle or last name. I am using StandardFilterFactory which takes care of such tokenization. But when I give a query which contain first/middle/last names seperated by spaces, it doesn't return the result which means that It din't match the query with the entity.
Code:
@Entity
@Indexed
@AnalyzerDef(name = "customanalyzer",
tokenizer = @TokenizerDef(factory =
StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = StandardFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class,
params = {
@Parameter(name = "language", value = "English")
})
})
public class Book implements Serializable{
@Id @GeneratedValue
private Long id;
@Field(index=Index.TOKENIZED, store=Store.NO)
@Analyzer(definition = "customanalyzer")
private String title;
@ManyToMany(cascade = CascadeType.ALL)
@IndexedEmbedded
@Analyzer(definition = "customanalyzer")
private List<Author> authors;
}
public class Author implements Serializable{
@Id @GeneratedValue
private Long id;
@Field(index=Index.TOKENIZED, store=Store.NO)
@Analyzer(definition="customanalyzer")
private String name;
}
In above code, author.name is the field I want to query. For example I have a author name "H.C.Verma" in the database. But when I query with the string "H C Verma", It doesn't return the entity containing "H.C.Verma" as the author. But when I give "H.C.Verma" as the query, then appropriate result is returned. Can you please help me?
I have one more query which is related to stemmer. I have "Mathematics" as one of the title of the book. But when I query for "Math" or "Maths", it doesn't return the result of entities containing "Mathematics" but when I query with "Mathematics", appropriate result is returned. How can I solve this issue too? I am using SnowballPorterFilterFactory which acts as a stemmer.