Thanks for the reply. I found one solution to modify DocList and DocSet after
searching.  Look At the following code snippet.

private void sortByRecordIDNew(SolrIndexSearcher.QueryResult result,
ResponseBuilder rb) throws IOException {

DocList docList = result.getDocListAndSet().docList;

SortedMap<Integer, Integer> sortedMap = null;
if (projectSort == 0) { 
       sortedMap = new TreeMap<Integer,
Integer>(Collections.reverseOrder());
}else{
       sortedMap = new TreeMap<Integer, Integer>();
}
                
Iterator iterator = docList.iterator();
while (iterator.hasNext()) {
        int docId = (int) iterator.next();
                
        Document d = rb.req.getSearcher().doc(docId);            
        Integer val = dbData.get(d.get("ID")); // dbData is a map contains
the recordId from the database  
                                                            // and the
Unique key in schema.xml 
                
        sortedMap.put(val, docId);

}

float[] scores = new float[docList.size()];
int[] docs = new int[docList.size()];
int docCounter = 0;
int maxScore = 0;

Iterator<Integer> it = sortedMap.keySet().iterator();
    while (it.hasNext()) {
           int recordID = (int) it.next();
           int docId = sortedMap.get(recordID);
           scores[docCounter] = 1.0f;
           docs[docCounter] = docId;
           docCounter++;
     } 
                
docList = new DocSlice(0, docCounter, docs, scores, 0, maxScore);

result.setDocList(docList);

}


Call this method from QueryComponent's process method after the searching.
In the above code I have sorted the DocList in ascending or descending order
depends upon the user requirement. It works for me.




--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-Can-I-modify-the-DocList-and-DocSet-in-solr-tp4140754p4141132.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to