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

Ignacio del Valle Alles updated LUCENE-4814:
--------------------------------------------

    Description: 
When performing a paginated search sorted by a STRING field, and documents 
without this field are present in the resultset, PagingFieldCollector stops 
collecting documents (or collects all documents, depending on sorting order) 
when one of the these documents are used as "after" element for the pagination.

The reason i have observed is that:
org.apache.lucene.search.FieldComparator.TermOrdValComparator.compareDocToValue(int
 doc, BytesRef value) (line 1160) always returns 1 in that case because value 
is null ("after" document sorting field value) whereas docValue (returned by 
termsIndex.getTerm) is a 0-length BytesRef for documents without that field.

A simple patch can be performed changing only this method with no (apparently) 
side-effects:
Current:
if (docValue == null) {
        if (value == null) {
Patched:
if (docValue == null || docValue.length==0) {
        if (value == null || value.length==0) {

Please excuse my lack of rigour, I'll try to attach the patch.
Regards


  was:
When performing a paginated search sorted by a STRING field, and documents 
without this field are present in the resultset, PagingFieldCollector stops 
collecting documents (or collects all documents, depending on sorting order) 
when one of the these documents are used as "after" element for the pagination.

The reason i have observed is that:
org.apache.lucene.search.FieldComparator.TermOrdValComparator.compareDocToValue(int
 doc, BytesRef value) (line 1160) allways returns 1 in that case because value 
is null ("after" document sorting field value) whereas docValue (returned by 
termsIndex.getTerm) is a 0-length BytesRef for documents without that field.

A simple patch can be performed changing only this method with no (apparently) 
side-effects:
Current:
if (docValue == null) {
        if (value == null) {
Patched:
if (docValue == null || docValue.length==0) {
        if (value == null || value.length==0) {

Please excuse my lack of rigour, I'll try to attach the path.
Regards


    
> PagingFieldCollector fails when sorting by String null fields
> -------------------------------------------------------------
>
>                 Key: LUCENE-4814
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4814
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/search
>    Affects Versions: 4.1
>            Reporter: Ignacio del Valle Alles
>            Priority: Minor
>              Labels: null, pagination, sorting
>
> When performing a paginated search sorted by a STRING field, and documents 
> without this field are present in the resultset, PagingFieldCollector stops 
> collecting documents (or collects all documents, depending on sorting order) 
> when one of the these documents are used as "after" element for the 
> pagination.
> The reason i have observed is that:
> org.apache.lucene.search.FieldComparator.TermOrdValComparator.compareDocToValue(int
>  doc, BytesRef value) (line 1160) always returns 1 in that case because value 
> is null ("after" document sorting field value) whereas docValue (returned by 
> termsIndex.getTerm) is a 0-length BytesRef for documents without that field.
> A simple patch can be performed changing only this method with no 
> (apparently) side-effects:
> Current:
> if (docValue == null) {
>         if (value == null) {
> Patched:
> if (docValue == null || docValue.length==0) {
>         if (value == null || value.length==0) {
> Please excuse my lack of rigour, I'll try to attach the patch.
> Regards

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to