这些是我的地方和类别课程:
@Entity
@Indexed
@AnalyzerDef(name = "placeAnalyzer", ...)
public class Place
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, updatable = false)
private Long id;
@Column(length = 100, nullable = false)
@Field
@Analyzer(definition = "placeAnalyzer")
private String name;
@OneToMany(mappedBy = "place", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@IndexedEmbedded
private Set<Category> categories;
...
}
@Entity
@Indexed
public class Category
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, updatable = false)
private Long id;
@Column(nullable = true)
@Field
@Analyzer(definition="placeAnalyzer")
private String name;
@ContainedIn
@ManyToOne
@JoinColumn(name="place_id")
private Place place;
}
这是我创建查询的方式:
Query searchStringQuery = queryBuilder.keyword()
.onFields("name", "location.city", "location.address", "categories.name")
.matching(TextUtils.stripAccents(searchString))
.createQuery();
但是当我搜索包含在类别表名字段中的某些文本时,搜索不会返回结果。它适用于查询中使用的其他字段。这有什么不对?