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