如何跨 2 个以上域对象映射 Grails Searchable 插件?
我在 Grails 应用程序中使用 Searchable 插件,但在返回有效搜索结果时无法使其映射到 2 个以上的域对象。我浏览了可搜索插件文档,但找不到我的问题的答案。这是我拥有的域的一个非常基本的示例:
class Article {
static hasMany = [tags: ArticleTag]
String title
String body
}
class ArticleTag {
Article article
Tag tag
}
class Tag {
String name
}
最终我想要做的是能够通过搜索文章的标题、正文和相关标签来查找文章。标题和标签也将得到提升。
映射这些类以满足所需结果的正确方法是什么?
I'm using the Searchable plugin in my Grails application, but am having trouble getting it to map across more than 2 domain objects while returning valid search results. I've looked through the Searchable plugin documentation, but cannot find the answer to my question. Here's a very basic example of the domains I have:
class Article {
static hasMany = [tags: ArticleTag]
String title
String body
}
class ArticleTag {
Article article
Tag tag
}
class Tag {
String name
}
Ultimately what I'm looking to do is be able to find articles by searching their titles, body and associated tags. The titles and tags would be boosted as well.
What's the proper way to map these classes to meet the desired results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能还有另一种方法,但这是我在应用程序中使用的简单方法。我向域对象添加了一个方法,以从标签中获取所有字符串值,并将它们添加到带有 Article 对象的索引中。
这允许我只搜索 Article 域对象并获取我需要的一切
There is probably another approach, but this is the simple approach I used in my application. I added a method to the domain object to get all of string values from the tags and add them to the index with the Article object.
This allows me to just search the Article domain object and get everything I need