具有多个属性和 FULLTEXT 搜索的 ArangoDB 查询
ArangoDB query with multiple attributes and FULLTEXT search
下面是我的 collection 结构,有 3 个 collection、图像、类别和标签
我想过滤所有 "images" 关键字(全文搜索)如 "cow" 并且属于 "animals" 类别并标记为 "photo"
如何使用 ArangoDB 执行此过滤器,我使用的是 nodejs / foxx 。请帮忙。
image{
filename:"myphoto.jpg",
filepath:"/opt/data/949b3e6194bf6f0ef3eb367a615826f8"
categories:[category/6401, category/6402],
tags:[tags/1002],
keywords:"photo green cow"
}
category{
_id:'category/6401',
name:"animals"
}
category{
_id:'category/6402',
name:"living things"
}
tags{
_id:'tags/1002',
name:"photo"
}
tags{
_id:'tags/1003',
name:"colors"
}
这里有一个请求:
FOR i IN FULLTEXT(image, "keywords", "cow") // First search for fulltext
FOR cat IN category // Then Loop on all categories
FILTER cat.name == "animals" // Filter by name
FILTER POSITION(i.categories, cat._id) == true // Join
FOR tag IN tags // Then Loop on all tags
FILTER tag.name == "photo" // Filter by name
FILTER POSITION(i.tags, tag._id) == true // Join
RETURN i // Return all images found
您的 image.keywords 字段必须设置全文索引
下面是我的 collection 结构,有 3 个 collection、图像、类别和标签
我想过滤所有 "images" 关键字(全文搜索)如 "cow" 并且属于 "animals" 类别并标记为 "photo"
如何使用 ArangoDB 执行此过滤器,我使用的是 nodejs / foxx 。请帮忙。
image{
filename:"myphoto.jpg",
filepath:"/opt/data/949b3e6194bf6f0ef3eb367a615826f8"
categories:[category/6401, category/6402],
tags:[tags/1002],
keywords:"photo green cow"
}
category{
_id:'category/6401',
name:"animals"
}
category{
_id:'category/6402',
name:"living things"
}
tags{
_id:'tags/1002',
name:"photo"
}
tags{
_id:'tags/1003',
name:"colors"
}
这里有一个请求:
FOR i IN FULLTEXT(image, "keywords", "cow") // First search for fulltext
FOR cat IN category // Then Loop on all categories
FILTER cat.name == "animals" // Filter by name
FILTER POSITION(i.categories, cat._id) == true // Join
FOR tag IN tags // Then Loop on all tags
FILTER tag.name == "photo" // Filter by name
FILTER POSITION(i.tags, tag._id) == true // Join
RETURN i // Return all images found
您的 image.keywords 字段必须设置全文索引