vespa.ai 中有什么方法可以使用打乱的查询字符串进行查询吗?
Is there any way in vespa.ai by which I can query with shuffled query strings?
我的数据集中有一个 full_name 字段,其中包含 first_name 和 last_name.
"fields": {
"full_name": "first_name last_name"
}
我需要使用以下条件进行查询-
//1. with first_name last_name
search/?yql=select * from sources test where full_name contains 'first_name last_name';
//2. with only first_name
search/?yql=select * from sources test where full_name contains 'first_name';
//3. with only last_name
search/?yql=select * from sources test where full_name contains 'last_name';
//4. with last_name first_name
search/?yql=select * from sources test where full_name contains 'last_name first_name';
我已经尝试将索引作为 index 并且我成功地使用第一个、第二个和第三个条件获取数据但无法使用第四个条件进行查询。
另外,有什么方法可以让 full_name 中 first_name 或 last_name 的拼写不正确,我仍然得到匹配的结果?
在 4 中,您创建了一个短语项目,同时您想要分隔使用 AND 组合的项目:
search/?yql=select * from sources test where full_name contains "last_name" and full_name contains "first_name";
或者,如果目标是匹配非结构化输入,您希望将该输入作为单独的请求参数发送:
search/?yql=select * from sources test where [{"defaultIndex": "full_name"}]userInput(@name);&name=first_name last_name
见https://docs.vespa.ai/documentation/reference/query-language-reference.html
您可以通过在查询中添加 &tracelevel=1 来查看查询是如何被解析的。
如果您需要构建各种形式的查询,通常最好在 Searcher 组件中根据原始请求参数执行此操作,而不是在客户端构建 YQL 字符串,请参阅 https://docs.vespa.ai/documentation/searcher-development.html。
我的数据集中有一个 full_name 字段,其中包含 first_name 和 last_name.
"fields": {
"full_name": "first_name last_name"
}
我需要使用以下条件进行查询-
//1. with first_name last_name
search/?yql=select * from sources test where full_name contains 'first_name last_name';
//2. with only first_name
search/?yql=select * from sources test where full_name contains 'first_name';
//3. with only last_name
search/?yql=select * from sources test where full_name contains 'last_name';
//4. with last_name first_name
search/?yql=select * from sources test where full_name contains 'last_name first_name';
我已经尝试将索引作为 index 并且我成功地使用第一个、第二个和第三个条件获取数据但无法使用第四个条件进行查询。
另外,有什么方法可以让 full_name 中 first_name 或 last_name 的拼写不正确,我仍然得到匹配的结果?
在 4 中,您创建了一个短语项目,同时您想要分隔使用 AND 组合的项目:
search/?yql=select * from sources test where full_name contains "last_name" and full_name contains "first_name";
或者,如果目标是匹配非结构化输入,您希望将该输入作为单独的请求参数发送:
search/?yql=select * from sources test where [{"defaultIndex": "full_name"}]userInput(@name);&name=first_name last_name
见https://docs.vespa.ai/documentation/reference/query-language-reference.html
您可以通过在查询中添加 &tracelevel=1 来查看查询是如何被解析的。
如果您需要构建各种形式的查询,通常最好在 Searcher 组件中根据原始请求参数执行此操作,而不是在客户端构建 YQL 字符串,请参阅 https://docs.vespa.ai/documentation/searcher-development.html。