solr查询字段不等于,solr过滤条件查询
Solr中使用条件过滤某个字段值
SearchService service = new SearchService();
service.setServerName("product");
SolrQuery solrQuery = new SolrQuery();
solrQuery.setStart(new Integer(0));
solrQuery.setRows(new Integer(10));
// ---过滤图片地址为http://xxxxx的记录
StringBuffer fqSB = new StringBuffer();
fqSB.append("-pictureurl:").append("http\\://xxxxx"); // 注意 “-pictrueurl” 中的中划线 “-” 就是“不等于”的意思
String fq = fqSB.toString();
solrQuery.addFilterQuery(new String[ ]{fq}); //过滤
//------------------------------------------------
solrQuery.setSortField("id", SolrQuery.ORDER.desc); //按id倒序
String queryString = query.toString();
solrQuery.setQuery(queryString);
SearchPage sp = null;
sp = service.query(solrQuery);
List productlist = new ArrayList();
productlist = sp.getResults();
Solr中使用条件过滤某个字段值
SearchService service = new SearchService();
service.setServerName("product");
SolrQuery solrQuery = new SolrQuery();
solrQuery.setStart(new Integer(0));
solrQuery.setRows(new Integer(10));
// ---过滤图片地址为http://xxxxx的记录
StringBuffer fqSB = new StringBuffer();
fqSB.append("-pictureurl:").append("http\\://xxxxx"); // 注意 “-pictrueurl” 中的中划线 “-” 就是“不等于”的意思
String fq = fqSB.toString();
solrQuery.addFilterQuery(new String[ ]{fq}); //过滤
//------------------------------------------------
solrQuery.setSortField("id", SolrQuery.ORDER.desc); //按id倒序
String queryString = query.toString();
solrQuery.setQuery(queryString);
SearchPage sp = null;
sp = service.query(solrQuery);
List productlist = new ArrayList();
productlist = sp.getResults();