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

Hoss Man commented on SOLR-12457:
---------------------------------

I was hoping to crank out a quick fix for this in time for 7.4, but the problem 
is more nuanced then i realized...

the {{FieldType}} {{marshalSortValue}} & {{unmarshalSortValue}} functions don't 
come into play in these cases because we're not sorting on a _field_ we're 
sorting on a _ValueSource_

As I speculated in my earlier comment, this means that the same problem occurs 
with string fields if you try something like 
{{sort=field(multivalued_string,min) asc}} ... but it does *NOT* affect you if 
you use the implicit min|max syntax added in SOLR-11854 (ie: 
{{sort=multivalued_string asc}} ) because in that case there is no ValueSource 
involved and the SortField used is directly tied to the (multivalued) field 
name -- so StrField's {{marshalSortValue}} & {{unmarshalSortValue}} methods 
(which handle the BytesRef/String conversion) take care of things for you.

NOTE: The same implicit min|max syntax  (ie: {{sort=multivalued_trie_field 
asc}} ) does *NOT* work for trie fields, because they don't override the 
default  {{marshalSortValue}} & {{unmarshalSortValue}} (even if we only cared 
about solving this bug for the implicit syntax, the marshalling methods don't 
have access to the {{SchemaField}}, so there's no easy way for the marshalling 
methods to know if the "field" being sorted on is multivalued or not -- so we'd 
have to do some kind of kludgy hack where the {{TrieField}} marshaling logic 
did instance of checks to decide if it should convert things)

----

At the moment, i can't think of a simple/clean fix for this.

> Multi valued field sorting doesn't work on trie fields
> ------------------------------------------------------
>
>                 Key: SOLR-12457
>                 URL: https://issues.apache.org/jira/browse/SOLR-12457
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>    Affects Versions: 7.1
>            Reporter: Varun Thacker
>            Priority: Major
>
> When I go to sort on a multi-valued field in a 2 shard collection, which has 
> trie fields the query fails.
> To reproduce we need 2+ shards, a multi-valued trie field and "desc" sort 
> criteria.
> Here's my schema
> {code:java}
> <dynamicField name="*_is" type="int" indexed="true" stored="true" 
> multiValued="true" docValues="true"/>
> <fieldType class="solr.TrieIntField" docValues="true" name="int" 
> positionIncrementGap="0" precisionStep="0"/>
> <dynamicField name="*_i" type="pint" indexed="true" stored="true" 
> multiValued="true"/>
> <fieldType name="pint" class="solr.IntPointField" docValues="true"/>
> {code}
> Now If I add a few docs
> {code:java}
> [
> {"id" : "1", "test_is" : ["1", "2", "3", "4", "5"], "test_i" : ["1", "2", 
> "3", "4", "5"]},
> {"id" : "2", "test_is" : ["1", "2", "3", "4", "5"], "test_i" : ["1", "2", 
> "3", "4", "5"]},
> {"id" : "3", "test_is" : ["1", "2", "3", "4", "5"], "test_i" : ["1", "2", 
> "3", "4", "5"]}
> ]{code}
> Works:
> [http://localhost:8983/solr/gettingstarted/select?q=*:*&sort=field(test_i,max)%20desc]
>  
> Doesn't Work:
> [http://localhost:8983/solr/gettingstarted/select?q=*:*&sort=field(test_is,max)%20desc]
>  
> To be more clear when I say it doesn't work , the query throws and error and 
> here's the stack trace for it:
> {code:java}
> ERROR - 2018-06-06 22:55:06.599; [c:gettingstarted s:shard2 r:core_node8 
> x:gettingstarted_shard2_replica_n5] org.apache.solr.common.SolrException; 
> null:java.lang.ClassCastException: java.lang.String cannot be cast to 
> org.apache.lucene.util.BytesRef
>         at 
> org.apache.lucene.search.FieldComparator$TermOrdValComparator.compareValues(FieldComparator.java:561)
>         at 
> org.apache.solr.handler.component.ShardFieldSortedHitQueue$1.compare(ShardFieldSortedHitQueue.java:161)
>         at 
> org.apache.solr.handler.component.ShardFieldSortedHitQueue$1.compare(ShardFieldSortedHitQueue.java:153)
>         at 
> org.apache.solr.handler.component.ShardFieldSortedHitQueue.lessThan(ShardFieldSortedHitQueue.java:91)
>         at 
> org.apache.solr.handler.component.ShardFieldSortedHitQueue.lessThan(ShardFieldSortedHitQueue.java:33)
>         at org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:263)
>         at org.apache.lucene.util.PriorityQueue.add(PriorityQueue.java:140)
>         at 
> org.apache.lucene.util.PriorityQueue.insertWithOverflow(PriorityQueue.java:156)
>         at 
> org.apache.solr.handler.component.QueryComponent.mergeIds(QueryComponent.java:924)
>         at 
> org.apache.solr.handler.component.QueryComponent.handleRegularResponses(QueryComponent.java:585)
>         at 
> org.apache.solr.handler.component.QueryComponent.handleResponses(QueryComponent.java:564)
>         at 
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:423)
>         at 
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:177)
>         at org.apache.solr.core.SolrCore.execute(SolrCore.java:2484)
>         at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:720)
>         at 
> org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:526){code}
>  



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

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

Reply via email to