问题描述
我在通过Solrj(运行Tomcat)选择25文档Solr(3.6)索引中的所有内容时遇到问题.
I am having issues selecting everything in my 25 document Solr (3.6) index via Solrj (running Tomcat).
public static void main(String[] args) throws MalformedURLException, SolrServerException {
SolrServer solr = new HttpSolrServer("http://localhost:8080/solr");
ModifiableSolrParams parameters = new ModifiableSolrParams();
parameters.set("?q", "*:*");
parameters.set("wt", "json");
QueryResponse response = solr.query(parameters);
System.out.println(response);
}
我得到的结果是:
{responseHeader={status=0,QTime=0,params={?q=*:*,wt=javabin,version=2}},response={numFound=0,start=0,docs=[]}}
此外,如果我接受?"在parameters.set("?q", "*:*");
中,我必须终止编译,否则它将超时.如果我替换
Also, If I take the "?" out of parameters.set("?q", "*:*");
I have to terminate the compilation or else it times out. The same happens if I replace the
"*:*"
仅
"*"
此外,我尝试parameters.set("qt", "/select");
无济于事.
Also, I have tried parameters.set("qt", "/select");
to no avail.
您如何选择全部并通过Solrj实际获得结果?
How do you select all and actually get results through Solrj?
推荐答案
我不确定为什么可行,但是在失败了一百个想法之后,这个想法就花了:
I am not sure why this works but after failing on a hundred ideas, this one took:
public static void main(String[] args) throws MalformedURLException, SolrServerException {
SolrServer solr = new HttpSolrServer("http://localhost:8080/solr");
ModifiableSolrParams parameters = new ModifiableSolrParams();
parameters.set("q", "*:*"); //query everything thanks to user1452132!
parameters.set("facet", true);//without this I cant select all
parameters.set("fl", "id");//send back just the id values
parameters.set("wt", "json");//Id like this in json format please
QueryResponse response = solr.query(parameters);
System.out.println(response);
}
希望这可以帮助某个人.
Hope this helps someone out there.
这篇关于Solrj全选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!