[ 
https://issues.apache.org/jira/browse/SOLR-8940?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hoss Man updated SOLR-8940:
---------------------------
    Attachment: SOLR-8940.patch

bq. I suspect this bug was introduced by a mistake in some of the refactoring 
in LUCENE-6900, ...

confirmed.  some near identical code was refactored into the (new in 5.5) 
transformToNativeShardDoc method, but the two places where the code was 
refactored were updated to include identical calls to this method with 
identical arguments including {{groupSort}} -- in one of those cases 
{{sortWithinGroup}} should have been used as the method arg instead.

----

Attaching a patch with fix and some new non trivial group.sort tests that 
demonstrate the bug w/o the fix applied

> ArrayIndexOutOfBoundsException in 
> TopGroupsResultTransformer.transformToNativeShardDoc after upgrading to 5.5.0
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-8940
>                 URL: https://issues.apache.org/jira/browse/SOLR-8940
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 5.5, 5.5.1
>            Reporter: Henrik
>            Priority: Blocker
>              Labels: 5.5, arrayindexoutofbounds, exception, query, 
> regression, search
>         Attachments: 
> 0001-SOLR-8940-Avoid-ArrayIndexOutOfBoundsException-in-To.patch, 
> SOLR-8940.patch, schema-types.xml, schema.xml, solr-query-exception.txt, 
> solrconfig.xml
>
>
> We get an ArrayIndexOutOfBoundsException when searching after upgrading to 
> solr 5.5.
> Here's the query:
> {code}
> "params":{
>       "q":"*:*",
>       "group.sort":"priceAmount asc,rnd desc",
>       "indent":"on",
>       "fl":"priceAmount,flightTripId,brand,slob,cabinType,tripDuration",
>       "group.limit":"100",
>       "fq":["searchId:e31a0c58-9056-4297-8d70-049017ba4906",
>         "doctype:offer",
>         "flightTripId:(DY6020421-SK2360519 OR DY6020421-SK2600519 OR 
> DY6020421-SK2620519 OR DY6020421-SK2740519 OR DY6020421-SK2900519 OR 
> DY6020421-SK2860519 OR DY6040421-SK2380519 OR DY6040421-SK2440519 OR 
> DY6040421-SK2480519 OR DY6040421-SK2520519 OR DY6040421-SK2600519 OR 
> DY6040421-SK2620519 OR DY6040421-SK2720519 OR DY6040421-SK2740519 OR 
> DY6040421-SK2800519 OR DY6040421-SK2840519 OR DY6040421-SK2820519 OR 
> DY6060421-SK2480519 OR DY6060421-SK2740519 OR DY6060421-SK2800519 OR 
> DY6060421-SK2840519 OR DY6060421-SK2900519 OR DY6060421-SK2860519 OR 
> DY6060421-SK2820519 OR DY6080421-SK2440519)",
>         "maximumLegDuration:[* TO 180]",
>         "departureAirportLeg1:(OSL)",
>         "(arrivalAirportLeg2:(OSL) OR (* NOT arrivalAirportLeg2:*))",
>         "arrivalAirportLeg1:(BGO)",
>         "(departureAirportLeg2:(BGO) OR (* NOT departureAirportLeg2:*))"],
>       "group.ngroups":"true",
>       "wt":"json",
>       "group.field":"flightTripId",
>       "group":"true"}}
> {code}
> And here's the exception:
> {code}
> ERROR [20160404T104846,333] qtp315138752-3037 
> org.apache.solr.servlet.HttpSolrCall - 
> null:java.lang.ArrayIndexOutOfBoundsException: 1
>         at 
> org.apache.solr.search.grouping.distributed.shardresultserializer.TopGroupsResultTransformer.transformToNativeShardDoc(TopGroupsResultTransformer.java:175)
>         at 
> org.apache.solr.search.grouping.distributed.shardresultserializer.TopGroupsResultTransformer.transformToNative(TopGroupsResultTransformer.java:137)
>         at 
> org.apache.solr.search.grouping.distributed.responseprocessor.TopGroupsShardResponseProcessor.process(TopGroupsShardResponseProcessor.java:129)
>         at 
> org.apache.solr.handler.component.QueryComponent.handleGroupedResponses(QueryComponent.java:750)
>         at 
> org.apache.solr.handler.component.QueryComponent.handleResponses(QueryComponent.java:733)
>         at 
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:405)
>         at 
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:155)
>         at org.apache.solr.core.SolrCore.execute(SolrCore.java:2082)
> {code}
> The exception is thrown at the last line here 
> (TopGroupsResultTransformer.java line 175):
> {code}
>   protected ScoreDoc[] transformToNativeShardDoc(List<NamedList<Object>> 
> documents, Sort groupSort, String shard,
>                                                  IndexSchema schema) {
>     [...]
>     for (NamedList<Object> document : documents) {
>       [...]
>       Object sortValuesVal = document.get("sortValues");
>       if (sortValuesVal != null) {
>         sortValues = ((List) sortValuesVal).toArray();
>         for (int k = 0; k < sortValues.length; k++) {
>           SchemaField field = groupSort.getSort()[k].getField() != null
>               ? schema.getFieldOrNull(groupSort.getSort()[k].getField()) : 
> null;
> {code}
> It's not obvious to me that {{sortValues.length == 
> groupSort.getSort().length}}, but I guess there's some logic behind it :)
> I have attached the schema and json result.
> The problem disappears when rolling back to 5.4.0.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to