Actually you're second example is probably a straight forward: reduce(select(...), group(...), by="k1")
Joel Bernstein http://joelsolr.blogspot.com/ On Thu, Jun 14, 2018 at 7:33 PM, Joel Bernstein <joels...@gmail.com> wrote: > Take a look at the reduce() function. You'll have to write a custom reduce > operation but you can follow the example here: > > https://github.com/apache/lucene-solr/blob/master/solr/ > solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java > > You can plug in your custom reduce operation in the solrconfig.xml and use > it like any other function. If you're interested in working on this you > could create a ticket and I can provide guidance. > > > Joel Bernstein > http://joelsolr.blogspot.com/ > > 2018-06-14 13:13 GMT-04:00 Christian Spitzlay < > christian.spitz...@biologis.com>: > >> Hi, >> >> is there a way to merge array values? >> >> Something that transforms >> >> { >> "k1": "1", >> "k2": ["a", "b"] >> }, >> { >> "k1": "2", >> "k2": ["c", "d"] >> }, >> { >> "k1": "2", >> "k2": ["e", "f"] >> } >> >> into >> >> { >> "k1": "1", >> "k2": ["a", "b"] >> }, >> { >> "k1": "2", >> "k2": ["c", "d", "e", "f"] >> } >> >> >> And an inverse of cartesianProduct() that transforms >> >> { >> "k1": "1", >> "k2": "a" >> }, >> { >> "k1": "2", >> "k2": "b" >> }, >> { >> "k1": "2", >> "k2": "c" >> } >> >> into >> >> { >> "k1": "1", >> "k2": ["a"] >> }, >> { >> "k1": "2", >> "k2": ["b", "c"] >> } >> >> >> Christian >> >> >> >