Typesense 'OR' 查询模式
Typesense 'OR' query mode
描述
我有一个案例,我想在单个集合中搜索多个查询标记,例如:
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 doesn't support strict ORs 目前没有这样做的计划。
为了解决我的问题,我使用了 filter_by
,而不是像这样:
let searchRequests = {
'searches': [
{
'collection': 'products',
'q': '*',
'filter_by': "category:["shoe", "hat", "dress", "perfume"]"
}
]
}
这将 return 类别 shoe/hat/dress/parfume 的所有产品。
有关 filter_by
用法的更多详细信息,请点击此处:https://typesense.org/docs/0.19.0/api/documents.html#index-a-document
描述
我有一个案例,我想在单个集合中搜索多个查询标记,例如:
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 doesn't support strict ORs 目前没有这样做的计划。
为了解决我的问题,我使用了 filter_by
,而不是像这样:
let searchRequests = {
'searches': [
{
'collection': 'products',
'q': '*',
'filter_by': "category:["shoe", "hat", "dress", "perfume"]"
}
]
}
这将 return 类别 shoe/hat/dress/parfume 的所有产品。
有关 filter_by
用法的更多详细信息,请点击此处:https://typesense.org/docs/0.19.0/api/documents.html#index-a-document