我从我的 URL 中获取了以下查询
public static String query="pen&mq=pen&f=owners%5B%22abc%22%5D&f=application_type%5B%22cde%22%5D";
我想使用这个查询来查询 solr
CommonsHttpSolrServer server = new CommonsHttpSolrServer( "http://localhost:8080/solr/");
server.setParser(new XMLResponseParser());
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(query);
QueryResponse qr =server.query(solrQuery);
SolrDocumentList sdl = qr.getResults();
System.out.println("Found: " + sdl.getNumFound());
我在 tomcat 日志文件中检查了我的查询,它被翻译为
path=/select params={version=2&wt=javabin&q=pen%26mq%3Dpen%26f%3Downers%255B%2522abc%2522%255D%26f%3Dapplication_type%255B%2522cde%2522%255D`
尽管有 500 个文档,但它给了我 0 个结果。我尝试使用解码我的查询
URLDecoder.decode(query,"UTF-8");
但后来它开始抱怨“[”标志。
org.apache.lucene.queryParser.ParseException: Encountered " "]" "]
我应该如何使用此查询查询 solr 服务器?是否需要解析查询并取每个过滤器的值然后使用
solrQuery.setFilterQueries()
方法。有人可以帮我吗