2017-05-19 3 views
0

Unten ist meine Sammlung Struktur, verfügt über 3 Sammlung, Bild, Kategorie und TagsArangoDB Abfrage mit mehreren Attributen und die Volltextsuche

Ich möchte alle „Bilder“ filtern, die Keyword (Volltextsuche) wie „Kuh“ hat und gehört zur Kategorie "Tiere" und verschlagwortet mit "Foto"

Wie kann ich diesen Filter mit ArangoDB, ich benutze nodejs/foxx. Bitte helfen Sie.

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

Antwort

0

hier eine Anfrage:

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 

Sie müssen einen Volltextindex zu Ihrem image.keywords Feld gesetzt haben

+0

Danke, werde ich versuchen, diese und lassen Sie wissen – Gireesh

+0

Es funktioniert, Danke Sie. – Gireesh

Verwandte Themen