描述
我有一个案例,我想在一个集合中搜索多个查询令牌,比如:
let searchRequests = {
'searches': [
{
'collection': 'products',
'q': 'shoe hat dress perfume',
}
]
}
如果我单独查询每个令牌,并且如果我查询两个类似的令牌:'q': 'shoe hat',
,则每个令牌都包含结果。
是否有允许两个以上查询项的方法
预期行为
我希望基于我的查询令牌'shoe hat dress perfume',
或换句话说OR
查询模式返回结果:
{
"results": [
{
"facet_counts": [],
"found": 100,
"hits": [
...
}
]
}
实际行为
实际行为是什么都没找到:
{
"results": [
{
"facet_counts": [],
"found": 0,
"hits": [
...
}
]
}
元数据
Typesense版本:0.22.0
Typesense不支持严格的OR,目前还没有这样做的计划。
为了解决我的问题,我使用了filter_by
,就像这样:
let searchRequests = {
'searches': [
{
'collection': 'products',
'q': '*',
'filter_by': "category:["shoe", "hat", "dress", "perfume"]"
}
]
}
这将退回鞋/帽/连衣裙/香水类的所有产品。
有关filter_by
使用的更多详细信息,请点击此处:https://typesense.org/docs/0.19.0/api/documents.html#index-a文档