[ 
https://jira.duraspace.org/browse/DS-1571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=28349#comment-28349
 ] 

Raul Ruiz commented on DS-1571:
-------------------------------

Hi all,

I was working over this bug and I have a solution.

To appear the nearest date range, you have to modify the method setFacet on 
DiscoverUtility.java.
The loop for write facet queries is incorrect. 
Incorrect version:
for (int year = topYear - gap; year > oldestYear
                                    && (facetQueries.size() < 11); year -= gap)
Correction:
for (int year = topYear; year > oldestYear
                                    && (facetQueries.size() < 11); year -= gap)
                            {

Now ordering over discovery is incorrect because some ranges are in incorrect 
position.


To solution this you have to modify class SolrServiceImpl.java. The method 
retrieveResult is incorrect. To order filter queries, is being used a treemap. 
The problem is that you try to order a string with numbers it order good for 
strings but wrong for integers. 
p.e. [2 - 999] [2000-2200] [1000-1999]
ORDER BY STRING: [2000-2200] [2 - 999] [1000-1999] 
ORDER BY INTEGER: [2000-2200] [1000-1999] [2 - 999]

The solution is to add zeros before currentTop date and bottom date.

Class DiscoverUtility.java look for set facet method and add:
 else
                                {
                                    // We need to do -1 on this one to
                                    // get a
                                    // better result
                                    currentTop--;
                                }
                                                                /*Patch*/
                                                                String 
bottomYearStr = String.valueOf(bottomYear);
                                                                String 
currentTopStr = String.valueOf(currentTop);
                                                                while( 
bottomYearStr.length() < 4){
                                                                        
bottomYearStr = "0" + bottomYearStr;
                                                                }
                                                                while( 
currentTopStr.length() < 4){
                                                                        
currentTopStr = "0" + currentTopStr;
                                                                }
                                                               /*End patch*/
                                                             
facetQueries.add(dateFacet + ":[" + bottomYearStr
                                                             + " TO " + 
currentTopStr + "]");


Class SolrServiceImpl.java look for retrieveResult method and add:


                    String name = facetQuery.substring(facetQuery.indexOf('[') 
+ 1);
                                        
                    name = name.substring(0, 
name.lastIndexOf(']')).replaceAll("TO", "-");
                                        /* ADD*/
                                        int bottomYear = 
Integer.parseInt(name.substring(0,4));
                                        int currentTop = 
Integer.parseInt(name.substring(7,11));
                                        name = bottomYear + 
name.substring(4,6)+ currentTop;
                                        /*End CHANGES*/
                                        
                    String filter = 
facetQuery.substring(facetQuery.indexOf('['));
                    filter = filter.substring(0, filter.lastIndexOf(']') + 1);


Now discovery display is correct but when you search with a date issued filter 
over discovery you must put a date with zeros if is less than 1000 to show 
results. P.e. 2 = 0002 , 99 = 0099 , 700 = 0700 ¿How can I solve this bug?

Thanks all




                
> DSpace discovery CRITICAL bug when date facet produce range
> -----------------------------------------------------------
>
>                 Key: DS-1571
>                 URL: https://jira.duraspace.org/browse/DS-1571
>             Project: DSpace
>          Issue Type: Bug
>          Components: JSPUI, XMLUI
>    Affects Versions: 3.0, 3.1
>            Reporter: Denis Fdz
>            Assignee: Andrea Bollini
>            Priority: Blocker
>         Attachments: jspui-facet-dtissued.jpg, screen-capture.png, 
> xmlui-facet-dtissued.jpg
>
>   Original Estimate: 2 days
>  Remaining Estimate: 2 days
>
> Hi all,
> I submitted some items to http://demo.dspace.org/jspui/ and I noticed that 
> discovery doesn't works fine.
> If I have big ranges of dates, the nearest date range doesn't appear.
> We should correct this as soon as posible.

--
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

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to