如何在yql查询中应用测试和设置条件

时间:2018-11-30 09:14:56

标签: vespa

以下是我的文档的搜索定义。我的文档中有一个字段“ expire”,它是一个时间戳。现在,我想使用yql查询(如果isActive =“ 1”和test.expire-now()> 0)搜索文档。我可以通过查询实现吗?

search test {
    document test {
                field Id type string {
                    indexing: index|summary
                }

                field isActive type string {
                    indexing: index|summary
                }

                field expire type long {
                   indexing: index | summary
                }

                field detail type string {
                   indexing: summary
                }
}

}

如果是,那么我的查询是什么?如何在查询中应用条件?请帮助

1 个答案:

答案 0 :(得分:1)

对此的YQL是

?query=select * from test where (isActive contains "1" and expire > nowTimestamp);&type=yql

您不能使用now(),因此需要自己插入时间戳。

您还可以在Searcher组件中构造查询(无需构造YQL字符串)。

相关问题