[ 
https://issues.apache.org/jira/browse/SOLR-12499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16517154#comment-16517154
 ] 

Markus Kalkbrenner commented on SOLR-12499:
-------------------------------------------

Using the proposed patch, this example produces the expected result.

Expression:

 
{code:java}
reduce(
 merge(
   sort(cartesianProduct(tuple(k1="1", k2=array(a)), k2, productSort="k1 asc"), 
by="k1 asc"),
   sort(cartesianProduct(tuple(k1="2", k2=array(b,c)), k2, productSort="k1 
asc"), by="k1 asc"),
   on="k1 asc"
 ),
 by="k1",
 fieldValueMerge(sort="k1 asc", n="10", mergeField=k2)
){code}
Result:
{code:java}
{
  "result-set": {
    "docs": [
      {
        "k1": "1",
        "k2": [
          "a"
        ]
      },
      {
        "k1": "2",
        "k2": [
          "b",
          "c"
        ]
      },
      {
        "EOF": true,
        "RESPONSE_TIME": 0
      }
    ]
  }
}
{code}
 

> Add reduce operation to merge field values
> ------------------------------------------
>
>                 Key: SOLR-12499
>                 URL: https://issues.apache.org/jira/browse/SOLR-12499
>             Project: Solr
>          Issue Type: New Feature
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: streaming expressions
>    Affects Versions: 7.3.1
>            Reporter: Christian Spitzlay
>            Priority: Major
>
> It would be nice to have a reduce operation that lets you collect the values 
> of a field from the group of tuples into an array.
> {code:java}
> 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"]
> }
> {code}
> and
> {code:java}
> {
>  "k1": "1",
>  "k2": "a"
> },
> {
>  "k1": "2",
>  "k2": "b"
> },
> {
>  "k1": "2",
>  "k2": "c"
> }
> into
> {
>  "k1": "1",
>  "k2": ["a"]
> },
> {
>  "k1": "2",
>  "k2": ["b", "c"]
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to