solrj setting query fields

siva :

Am using the below solr query which works

https://host:port/solr/ref_cm/select?defType=edismax&q=abc&qf=a+b+c+d

May I know how to set the same using solrj. I tried below with "qf" but it doesnt work (even though from url it works)

final Map<String, String> queryParamMap = new HashMap<String, String>();

queryParamMap.put("q", query);
queryParamMap.put("defType", "edismax");
queryParamMap.put("qf","a, b, c, d");

Appreciate any pointers

Abhijit Bashetti :

You can try below part of the code. it should work for you.

The code queryParamMap.put("qf", "a b c d") would work instead of queryParamMap.put("qf","a, b, c, d").

The full code would be something like below.

ModifiableSolrParams queryParamMap= new ModifiableSolrParams();
queryParamMap.set("q", "test");
queryParamMap.set("defType", "edismax");
queryParamMap.set("qf", "a b c d");
QueryResponse qResp = cloudSolrClient.query(queryParamMap);
SolrDocumentList docList = qResp.getResults();
int numFound = (int) docList.getNumFound();

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=328729&siteId=1