【问题标题】:ArangoDB query with multiple attributes and FULLTEXT search具有多个属性和 FULLTEXT 搜索的 ArangoDB 查询
【发布时间】:2017-05-23 17:55:12
【问题描述】:

下面是我的收藏结构,有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"
}

【问题讨论】:

    标签: arangodb arangojs


    【解决方案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 字段设置全文索引

    【讨论】:

    • 谢谢,我会试试这个,让你知道
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    相关资源
    最近更新 更多