0

下面是我的收藏结构,有3个收藏,图片,类别和标签

我想过滤所有具有关键字(全文搜索)的“图像”,如“牛”,属于“动物”类别并标记为“照片”

如何使用 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"
}
4

1 回答 1

1

这里有一个请求:

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 字段设置全文索引

于 2017-05-23T09:55:12.647 回答