Using Arangosearch and filtering on edges

69 views
Skip to first unread message

Fredrik Sjöholm

unread,
Aug 20, 2020, 11:05:01 AM8/20/20
to ArangoDB
I have a View which is linked to a collection where I want to search for documents. I also want to filter results so that only documents which are linked to a particular document in a different collection are shown. 

My query looks like this:

with Category
let myCategoryId = first(for c in Category filter c.name == "MyCategoryName" return c._id)
for product in ProductView
  search phrase(product.name, "MyProductName", "text_en")
  let n = length(for c in 1..1 outbound product ProductCategory filter c._id == myCategoryId return 1)
  filter n > 0
  return product.name

This returns all Products which are linked to the Category "MyCategoryName" through the ProductCategory edge. It works nice, but the filtering by category makes it much slower. Is there any way I can use Arangosearch instead of Filter?

Sergey Zak

unread,
Feb 28, 2021, 8:08:33 PM2/28/21
to ArangoDB
You ways to connect data seem suboptimal.
If you only want to return products that are linked to "MyCategoryName", why not start your traversal there?

for c in Category filter c.name=='MyCategoryName'
for product in 1 inbound c ProductCategory
Reply all
Reply to author
Forward
0 new messages