如何在流口水规则语言中连接两个查询



>我有两个查询用于查找特定项目,它们如下:

query "score" (double s)
    Item( score > s )
end
query "price" (double p)
    Item( price < p )
end

以下查询用于查找score > s or price < p项:

query "price or score" (double p, double s)
    price(p;) or score(s;)
end

我的问题是如何找到所有项目score > s and price < p

以下查询不起作用。它执行交叉联接,而不是内部联接。

query "price and score" (double p, double s)
    price(p;) and score(s;)
end

谢谢

此查询提供价格为 p <和分数> s 的项目事实:

query "price and score" (double p, double s)
    item: Item(price < p, score > s)
end

若要将查询组合为两个查询的组合,必须提供一个变量来绑定对事实的引用:

query "score" (double s, Item item)
    Item( this == item, score > s )
end
query "price" (double p, Item item)
    Item( this == item, price < p )
end
query "price and score" (double p, double s )
    price(p, item; ) and score(s, item; )
end

最新更新