0

Below is my collection structure, has 3 collection, image, category and tags

I want to filter all "images" which has keyword (FULLTEXT search) like "cow" and belongs to "animals" category and tagged with "photo"

How can I do this filter with ArangoDB, I am using nodejs / foxx . Please help.

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"
}

1 Answer 1

1

Here a request :

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

You must have a fulltext index set to your image.keywords field

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I will try this and let you know

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.