I want to write a custom Solr query and sorting and when I am calling
http://127.0.0.1:8983/solr/techproducts/select?q={!myparsername}12&sort=uid
desc, some of the section as marked is not getting called.

Issue: Documentation of solr customization is pretty poor

Help: Can you please tell why my code is not getting called.

Why I needed customization: Based on logged in user info like user age,
location and 10 other parameters I need to sort. Also, need sorting value
for tagging.
Default Solr expression is very costly.

    === class-1==
    
    public class MyPlugin extends QParserPlugin {
    
        @Override
        public QParser createParser(String qstr, SolrParams localParams,
SolrParams params, SolrQueryRequest req) {
                return new CustomQParser(qstr, localParams, params, req);       
        
        }
        
        private static class CustomQParser extends QParser{
    
                private Query innerquery;
                
                public CustomQParser(String qstr, SolrParams localParams, 
SolrParams
params, SolrQueryRequest req) {
    //--> getting called ...(1)
                        super(qstr, localParams, params, req);
                        try {
                                QParser parser = getParser(qstr, getReq());
                                this.innerquery = parser.parse();
                        }catch(SyntaxError ex) {
                                throw new RuntimeException("error parsing 
query", ex);
                        }
                }
    
                @Override
                public Query parse() throws SyntaxError {
    //--> getting called ...(2)
                        return new MatchTheQuery(innerquery);
                }
                
        }
    
    }
    
    
    == class-2 == 
    public class MatchTheQuery extends CustomScoreQuery {
        
        private Query subquery;
        
        public MatchTheQuery(Query subquery) {
    //--> getting called ...(3)
                super(subquery); 
                this.subquery = subquery;
        }
        
        @Override
        protected CustomScoreProvider getCustomScoreProvider(LeafReaderContext
context) {
    // not getting called :-(
                return new MyScoreProvider(subquery, context);
        }
    }
    
    == class-3 == 
    public class MyScoreProvider extends CustomScoreProvider {
        
        private Query subquery;
        
        public MyScoreProvider(Query subquery, LeafReaderContext context) {
                super(context);
                this.subquery = subquery;
        }
        
        @Override
        public float customScore(int doc, float subqueryScore, float
valSrcScores[]) throws IOException {
                                
    // not getting called :-(
    
        }
        
    
    }



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Reply via email to