Query only a subset of a string array

What I want to do

Imagine I have nodes of type A, and those nodes have a long array of strings. I want to query the nodes that have a string in the array that matches my search but only return the matched array terms instead of the whole array.

example

A1 {
    strings: ["apple", "banana", "orange", "pear", "pineapple"]
}

A2 {
    strings: ["appleton", "london","liverpool"]
}

A3 {
    strings: ["ninja", "dinosaur", "unicorn", "starlord"]
}

if i query for “apple” I want dgraph to return something like this:

query: [
    A1: {
        strings: [ "apple","pineapple"]
    },
    A2: {
        strings: ["appleton"]
    }

What I did

query(func: regexp(strings,/apple/i) {
    strings
}

and this excludes A3, which is nice but it returns the whole strings array for each node

query: [
    A1: {
        strings: ["apple", "banana", "orange", "pear", "pineapple"]
    },
    A2: {
        strings: ["appleton", "london","liverpool"]
    }

Is there any way of make this work with the arrays?
Thank you

In the current state of Dgraph, I don’t believe there is a way to do what you want.

Sets of strings can be used to filter nodes, but no logic to filter the sets themselves.

Furthermore, FYI from personal experience, regex function filters can become quite slow when you start working with a slightly large dataset. And there is also the restrictions that you cannot search for a regex if it is less than 3 characters long.

This might interest you: