I have successfully implemented the custom search in solr by extending CustomScoreProvider. But the problem is i need to pass some user info like 31,1 which i need in custom sort.
q={!mycustomparser}31+1+*:*
and it is acting as a text search. Is there any way that i can skip this text search and can just pass the user info.
some code.
public class MyCustomParserPlugin extends QParserPlugin {
@Override
public QParser createParser(String querystring, SolrParams slocParams, SolrParams params, SolrQueryRequest req) {
return new MyCustomParser(querystring, slocParams, params, req);
}
private static class MyCustomParser extends QParser{
private Query inQuery;
public MyCustomParser(String querystring, SolrParams slocParams, SolrParams params, SolrQueryRequest req) {
super(querystring, slocParams, params, req);
try {
QParser parser = getParser(querystring, getReq());
this.inQuery = parser.parse();
}catch(SyntaxError ex) {
throw new RuntimeException("error parsing query", ex);
}
}
@Override
public Query parse() throws SyntaxError {
return new MatchingQuery(inQuery);
}
}
}
=========================================
public class MatchingQuery extends CustomScoreQuery {
private Query subQuery;
public MatchingQuery(Query subQuery) {
super(subQuery);
this.subQuery = subQuery;
}
@Override
protected CustomScoreProvider getCustomScoreProvider(LeafReaderContext context) {
return new MyCustomSortClz(subQuery, context);
}
}
=========================================
public class MyCustomSortClz extends CustomScoreProvider {
// ---> my sort
}