在搜索查询中包含相关资源的最佳做法是什么?
我的资源是:
/projects
/participants
/questions
/questionAnswers
查询类似于:获取所有参与者:
- between the age of 20 and 40 and,
- male and,
- selected answer X of question y
会是什么样的
/与会者搜索=性别:雄性,年龄> = 20,年龄< = 40,问题:X,答案为:y
此类查询是否有更好或更标准的方式?
答案 0 :(得分:0)
你可以使用对象序列化&过滤器。 喜欢:
/ participant?filter = {gender = {male},age = {between = {20,40}},question = {x},answer = {y}}
给出的例子:
在这种情况下,您可以过滤更具体和/或组合。 例如:
的组合/ participant?filter = {gender = {male,female},age = {21,22,23,from = {40}},question = {x},answer = {y}}
结果:性别男女21岁,22岁,23岁,40岁至99岁(或您想要的)