Code:
...
import org.hibernate.search.annotations.Boost;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@Entity
@Indexed
@SequenceGenerator(name="subjectSeq", sequenceName="subjectSeq")
public class AppInfo {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="subjectSeq")
public Integer id;
public Integer district;
@Field
@Boost(2.0f)
public String appName;
public String thumbnail;
public Integer statistics;
@Field
public String description;
public Integer publisher;
public Date publishAt = new Date();
@ManyToOne
@IndexedEmbedded
@Boost(1.5f)
@JoinColumn(name="type")
public AppType type;
@ManyToMany
@JoinTable(name="appInfo_appCatalog",
joinColumns={@JoinColumn(name="info_id", referencedColumnName="id")},
inverseJoinColumns={@JoinColumn(name="catalog_id", referencedColumnName="id")})
@IndexedEmbedded
@Boost(1.5f)
public List<AppCatalog> catalogs;
public Integer status = 0;
public int state;
public int isPopular;
}
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import org.hibernate.search.annotations.Field;
@Entity
@SequenceGenerator(name="appTypeSeq", sequenceName="appTypeSeq")
public class AppType {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="appTypeSeq")
public Integer id;
@Field
public String name;
}
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import org.hibernate.search.annotations.Field;
@Entity
@SequenceGenerator(name="appCatalogSeq", sequenceName="appCatalogSeq")
public class AppCatalog {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="appCatalogSeq")
public Integer id;
@Field
public String name;
}
I user the following query code:
Code:
QueryBuilder qb = fullTextEntityManager.getSearchFactory()
.buildQueryBuilder().forEntity( AppInfo.class ).get();
org.apache.lucene.search.Query query = qb
.keyword().fuzzy()
.onFields("appName", "description", "type.name", "catalogs.name")
.matching(searchString)
.createQuery();
I use
Luke to find
type.id, catalogs.id indexed, but
type.name and
catalogs.name not indexed. I check the hibernate search document carefully and cannot find any problem with my codes.
I also check that the data inserted into database are OK, and most part of the data are indexed.
Who can help tell me why?