mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Improved resilience of query object when index is lacking necessary information, improve efficiency of search results by not using handles if the resource ID is available
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2521 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -165,14 +165,24 @@ public class DSQuery
|
||||
Query myquery = qp.parse(querystring);
|
||||
Hits hits = null;
|
||||
|
||||
if (args.getSortOption() == null)
|
||||
try
|
||||
{
|
||||
hits = searcher.search(myquery, new Sort(new SortField[] { new SortField("type"), SortField.FIELD_SCORE }));
|
||||
if (args.getSortOption() == null)
|
||||
{
|
||||
hits = searcher.search(myquery, new Sort(new SortField[] { new SortField("type"), SortField.FIELD_SCORE }));
|
||||
}
|
||||
else
|
||||
{
|
||||
SortField[] sortFields = new SortField[] { new SortField("type"), new SortField("sort_" + args.getSortOption().getName(), SortOption.DESCENDING.equals(args.getSortOrder())), SortField.FIELD_SCORE };
|
||||
hits = searcher.search(myquery, new Sort(sortFields));
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
SortField[] sortFields = new SortField[] { new SortField("type"), new SortField("sort_" + args.getSortOption().getName(), SortOption.DESCENDING.equals(args.getSortOrder())), SortField.FIELD_SCORE };
|
||||
hits = searcher.search(myquery, new Sort(sortFields));
|
||||
// Lucene can throw an exception if it is unable to determine a sort time from the specified field
|
||||
// Provide a fall back that just works on relevancy.
|
||||
log.error("Unable to use speficied sort option: " + (args.getSortOption() == null ? "type/relevance": args.getSortOption().getName()));
|
||||
hits = searcher.search(myquery, new Sort(SortField.FIELD_SCORE));
|
||||
}
|
||||
|
||||
// set total number of hits
|
||||
|
Reference in New Issue
Block a user