0
我有我从我的网址采取了以下查询查询Solr中
public static String query="pen&mq=pen&f=owners%5B%22abc%22%5D&f=application_type%5B%22cde%22%5D";
我想用这个查询
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日志文件来查询Solr的,它是翻译为
path=/select params={version=2&wt=javabin&q=pen%26mq%3Dpen%26f%3Downers%255B%2522abc%2522%255D%26f%3Dapplication_type%255B%2522cde%2522%255D`
它给了我0结果,尽管有500个文档。 我试图用
URLDecoder.decode(query,"UTF-8");
我的查询进行解码,但随后开始抱怨“[”的迹象。
org.apache.lucene.queryParser.ParseException: Encountered " "]" "]
我该如何查询使用此查询的solr服务器? 是否有必要以解析该查询并取每个滤波器的值,然后使用
solrQuery.setFilterQueries()
方法。有人可以帮我这么做
因此,我需要解析从url中获取的查询字符串 – sparkle
在使用SolrJ的情况下,是的。您不能直接从Solr管理页面(我假设)构建的直接URL将其粘贴到SolrJ中作为查询。您需要使用SolrJ方法构建相同的参数。我会回答你的问题中的所有参数。 –