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

Christine Poerschke commented on SOLR-6203:
-------------------------------------------

Hi Judith,

Thanks for following up on this ticket!

I've tried to remind myself about where we had left things by applying your 
Dec5th patch to the 
[jira/solr-6203|https://github.com/apache/lucene-solr/tree/jira/solr-6203] 
working branch and then merging in the master branch changes including the 
SOLR-9890 piece. After resolving the merges "it compiles" but i haven't run any 
tests or anything.

>From your Dec 2nd comments:

bq. ... I got to wondering about the call to schema.getFileOrNull() in the new 
implWeightSortSpec() function from the SOLR-9660 patch. That function allows 
the dynamic '*' field to lay claim to schema fields which SortSpecParsing 
carefully protected from it, just as it does when called by the 
XXXResultTransformer functions we are gearing up to modify. ...

Merging the master branch into the working branch didn't help too much with 
jogging my memory, but this sounds like a very good lead.

_The schema.getFileOrNull() let's the dynamic '\*' field claim 
'sqrt(popularity) desc' (or is it only 'popularity'?) from the sort whereas in 
SortSpecParsing there's the [// short circuit test for a really simple field 
name ... // let's try it as a function 
instead|https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/search/SortSpecParsing.java#L103-L108]
 logic which protects the sort from being misinterpreted as a '\*' dynamic 
field._

That is how I read your comment combined with the code, are we on the same page 
on this point? Assuming we are, and I think we are, then yes your 
weightSort/rewrite/createWeight and implWeightSortSpec observations and 
questions make sense to me.

So, following in that direction, the 'solution under consideration' is then:
* pass SortSpec rather than just Sort around (much of that already done via 
linked preparatory refactors)
* have the ShardResultTransformer classes use the SortSpec's SchemaField 
objects because
** the Sort's SortField requires use of IndexSchema.getFieldOrNull for 
conversion into a SchemaField object
** IndexSchema.getFieldOrNull does not protect the sort function from being 
misinterpreted as a '*' dynamic field
** the SortSpec's SchemaField objects require no conversion
** the SortSpec's SchemaField objects originally came from SortSpecParsing 
which afforded protection from the '*' dynamic field

Does that summary make sense so far? Assuming it does, then on to the 
'complication and remaining questions':
* QueryComponent didn't just use the Sort 'as it is' but it does this (not 
fully understood by us) 'weighting of sort' thing
* 'weighting of sort' is a SolrIndexSearcher 
[thing|https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L1001-L1004]
* as part of the SOLR-9660 refactor QueryComponent doing 'weighting of sort' 
became 'weighting of sort spec' which is still a SolrIndexSearcher 
[thing|https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L1006-L1030]
* 'weighting of sort spec' needs to consider the SchemaField objects in the 
sort spec
** question 1: is it fair to assume that the SchemaField objects of the 
original and the rewritten/weighted sort match?
** question 2: if rewriting/weighting turns the original sort into a null sort, 
what should the SchemaField objects be for the rewritten/weighted sort spec?

Right, okay, that was a lot of writing, thank you for reading this far :-)

Does it sort of (no pun intended) help sum up where we think we are here?

If it does then the next step (not for today) will be to find answers to the 
two open questions and decide on how to proceed with the patch/working branch.

Have a nice weekend!

Christine

> cast exception while searching with sort function and result grouping
> ---------------------------------------------------------------------
>
>                 Key: SOLR-6203
>                 URL: https://issues.apache.org/jira/browse/SOLR-6203
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 4.7, 4.8
>            Reporter: Nate Dire
>            Assignee: Christine Poerschke
>         Attachments: README, SOLR-6203.patch, SOLR-6203.patch, 
> SOLR-6203.patch, SOLR-6203.patch, SOLR-6203.patch, SOLR-6203.patch, 
> SOLR-6203-unittest.patch, SOLR-6203-unittest.patch
>
>
> After upgrading from 4.5.1 to 4.7+, a schema including a {{"*"}} dynamic 
> field as text gets a cast exception when using a sort function and result 
> grouping.  
> Repro (with example config):
> # Add {{"*"}} dynamic field as a {{TextField}}, eg:
> {noformat}
> <dynamicField name="*" type="text_general" multiValued="true" />
> {noformat}
> #  Create  sharded collection
> {noformat}
> curl 
> 'http://localhost:8983/solr/admin/collections?action=CREATE&name=test&numShards=2&maxShardsPerNode=2'
> {noformat}
> # Add example docs (query must have some results)
> # Submit query which sorts on a function result and uses result grouping:
> {noformat}
> {
>   "responseHeader": {
>     "status": 500,
>     "QTime": 50,
>     "params": {
>       "sort": "sqrt(popularity) desc",
>       "indent": "true",
>       "q": "*:*",
>       "_": "1403709010008",
>       "group.field": "manu",
>       "group": "true",
>       "wt": "json"
>     }
>   },
>   "error": {
>     "msg": "java.lang.Double cannot be cast to 
> org.apache.lucene.util.BytesRef",
>     "code": 500
>   }
> }
> {noformat}
> Source exception from log:
> {noformat}
> ERROR - 2014-06-25 08:10:10.055; org.apache.solr.common.SolrException; 
> java.lang.ClassCastException: java.lang.Double cannot be cast to 
> org.apache.lucene.util.BytesRef
>     at 
> org.apache.solr.schema.FieldType.marshalStringSortValue(FieldType.java:981)
>     at org.apache.solr.schema.TextField.marshalSortValue(TextField.java:176)
>     at 
> org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.serializeSearchGroup(SearchGroupsResultTransformer.java:125)
>     at 
> org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.transform(SearchGroupsResultTransformer.java:65)
>     at 
> org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.transform(SearchGroupsResultTransformer.java:43)
>     at 
> org.apache.solr.search.grouping.CommandHandler.processResult(CommandHandler.java:193)
>     at 
> org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:340)
>     at 
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)
>     at 
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
>   ...
> {noformat}
> It looks like {{serializeSearchGroup}} is matching the sort expression as the 
> {{"*"}} dynamic field, which is a TextField in the repro.



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

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

Reply via email to