You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Peyman Faratin <pe...@robustlinks.com> on 2013/03/21 18:13:30 UTC
setting bq in searchcomponent
Hi
If I run a main query "cheeze" jointly with a boost query "bq=spell:"cheeze" (boosting results with spell field "cheeze"), as
/select?fl=title&qf=main&bq=spell:"cheeze"&bq=trans:"cheeze"&q=cheeze
everything works fine. And defType=dismax
What I'd like to do is to programmatically generate the bq query inside a custom searchcomponent's "process" method and issue the query similar to above. I can achieve my goal with explicitly constructing and running a query as follows
StringBuilder QueryStr = new StringBuilder();
QueryStr.append("echoParams=none");
QueryStr.append("&debugQuery=off");
QueryStr.append("&defType=dismax");
QueryStr.append("&df=main");
QueryStr.append("&q="+token);
QueryStr.append("&bq=spell:"+token);
QueryStr.append("&bq=trans:"+token);
SolrParams query = SolrRequestParsers.parseQueryString(QueryStr.toString());
rb.req.setParams(query);
Query q = QParser.getParser(token, defType, rb.req).parse();
DocList hits = searcher.getDocList(q,rb.getFilters(),Sort.RELEVANCE,offset,rows,fieldFlags);
But is there a way to directly set the request What would be the best way to do this?
public void process(ResponseBuilder rb) throws IOException {
...
String token = rb.req.getParams().get("token");
String bqfield = rb.req.getParams().get(DisMaxParams.BQ);
.....
Query q = QParser.getParser(token, defType, rb.req).parse();
DocList hits = searcher.getDocList(q,rb.getFilters(),Sort.RELEVANCE,offset,rows,fieldFlags);
}
without having to explicitly constructing the query?
thank you
Peyman