You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Joel Bernstein (JIRA)" <ji...@apache.org> on 2017/03/10 19:04:04 UTC

[jira] [Commented] (SOLR-10085) Streaming Expressions result-set fields not in order

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

Joel Bernstein commented on SOLR-10085:
---------------------------------------

With the Apache Calcite release having the fields out of order on direct requests to /sql is more of an issue. This is because by default the aggregate fields are referred to like this: $EXPR1. The 1 is the column number in the field list. So having aggregate fields out of order makes it very difficult to just read the results from /sql without using field aliases. 

I think that we can maintain the field order for responses from /sql by making some small changes. These changes would only effect the output from /sql, not /stream or /graph.

The basic approach would be to make instance variables for the field list and alias list in the Tuple class. Then change the Tuple.writeMap method to iterate the field list when it writes out the fields. If the field list is null, it will simply iterate the internal map as it does now.

The field list in the Tuple class could be populated inside of the SQLHandler. In the StreamHandler this field list would not be populated.

I'll take a crack at implementing this an change the name of this ticket to be about SQL instead of streaming.

> Streaming Expressions result-set fields not in order
> ----------------------------------------------------
>
>                 Key: SOLR-10085
>                 URL: https://issues.apache.org/jira/browse/SOLR-10085
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: faceting
>    Affects Versions: 6.3
>         Environment: Windows 8.1, Java 8
>            Reporter: Yeo Zheng Lin
>              Labels: json, streaming
>
> I'm trying out the Streaming Expressions in Solr 6.3.0. 
> Currently, I'm facing the issue of not being able to get the fields in the result-set to be displayed in the same order as what I put in the query.
> For example, when I execute this query:
>  http://localhost:8983/solr/collection1/stream?expr=facet(collection1,
>       q="*:*",
>       buckets="id,cost,quantity",
>       bucketSorts="cost desc",
>       bucketSizeLimit=100,
>       sum(cost), 
>       sum(quantity),
>       min(cost), 
>       min(quantity),
>       max(cost), 
>       max(quantity),
>       avg(cost), 
>       avg(quantity),
>       count(*))&indent=true
> I get the following in the result-set.
>    {
>   "result-set":{"docs":[
> 	{
>     "min(quantity)":12.21,
>     "avg(quantity)":12.21,
>     "sum(cost)":256.33,
>     "max(cost)":256.33,
>     "count(*)":1,
>     "min(cost)":256.33,
>     "cost":256.33,
>     "avg(cost)":256.33,
>     "quantity":12.21,
>     "id":"000001",
>     "sum(quantity)":12.21,
>     "max(quantity)":12.21},
> 	{
>     "EOF":true,
>     "RESPONSE_TIME":359}]}}
> The fields are displayed randomly all over the place, instead of the order sum, min, max, avg as in the query. This may cause confusion to user who look at the output.  Possible improvement to display the fields in the result-set in the same order as the query



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org