我需要通过用户最喜欢和被阻止的标签来过滤 LicenseeQuery。当用户有一些最喜欢和被阻止的标签时,我已经完成了这项工作,但我正在努力解决用户没有最喜欢或被阻止的标签的情况。我相信我需要使用 MatchAllDocsQuery 的等价物,但我看不到如何通过 RavenDB 客户端 API 实现这一点。
当用户有一个或多个收藏夹和一个或多个被屏蔽的标签时,这可以正常工作:
string favesQuery = String.Join(" OR ", user.FavouriteTags.Select(x => String.Format("Tags:{0}", x)));
string blockedQuery = String.Join(" AND ", user.BlockedTags.Select(x => String.Format("-Tags:{0}", x)));
var articles = RavenSession.Advanced
.LuceneQuery<Article>("AllDocs/ByTags")
.Include(x => x.Author)
.Where(favesQuery)
.Boost(0.5m)
.Where(blockedQuery)
.OrderByDescending(x => x.DatePublished);
我得到的直接问题是Missing where clause
,但这是因为String.Join
当为空时返回一个空字符串user.FavouriteTags
。我可以在 and 前面加上一些东西favesQuery
吗blockedQuery
?
用 SQL 术语思考,我正在寻找相当于WHERE 1=1 AND ...
相关问题https://groups.google.com/forum/?fromgroups=#!topic/ravendb/JKTpHiFRJLc