2017-05-19 49 views
0

下面是我收集的结构,具有3集,图像,类别和标签ArangoDB查询具有多个属性和全文搜索

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

我该如何使用ARngoDB做这个过滤器,我使用的是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" 
} 

回答

0

这里的请求:

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场

+0

谢谢你,我会尝试这一点,并让你知道 – Gireesh

+0

它的工作原理,谢谢您。 – Gireesh