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

Christian Spitzlay commented on SOLR-12499:
-------------------------------------------

Sorry, the flu has knocked me out for some days.

And now I will be away for a couple of weeks. Markus Kalkbrenner may take over 
and go forward with this. He has write access to my github repository.
 * The current implementation just copies the values from the first document in 
the group (The sort order may still be something to check, it seems to be 
backwards w.r.t. what I would have expected). I kept that behaviour the way it 
was in GroupOperation.
 * I can imagine a case where the different documents share some values but not 
others.  For the shared values the user would end up with an array of identical 
values, one from each document which would make handling the result harder. 
Maybe one could provide a list of fields to be merged instead of a single one?
 * The name "flatten" makes sense if one thinks of a group of documents being 
reduced to a single one but I think that is already expressed by the "reduce". 
It think the name of the group operation should specifically express what is 
special about the way it treats the values. One could imagine operations that 
calculate min, max, sum, ... of a given field, for example (although that can 
already be done with rollup, if I understand correctly). The new operation 
merges values from the single documents (arrays or scalars) into an array under 
the same name. So mergeFieldValue seemed straightforward to me. Maybe there's a 
better name of course but I think flatten does not explain what the function 
does at least not how I understand the word flatten.

 

> 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