我的schema.xml配置文件:
inrowkey
我的java 查询代码:
public void query() throws SolrServerException, IOException {
Configuration conf = this.getCon();
HTable table = new HTable(conf, "myTable");
Get get = null;
List list = new ArrayList();
String url = "http://localhost:8080/solr";
SolrServer server = new HttpSolrServer(url);
//SolrQuery query = new SolrQuery("XM:张*"); //这种方式查询不出来
SolrQuery query = new SolrQuery("SFZH:101110203217");//这种方式可以
query.setStart(0); // 数据起始行,分页用
query.setRows(10); // 返回记录数,分页用
QueryResponse response = server.query(query);
SolrDocumentList docs = response.getResults();
System.out.println("文档个数:" + docs.getNumFound());
System.out.println("查询时间:" + response.getQTime());
我也不知道为什么?我的也是中文的查不出来,数字和英文可以
我的问题解决了,在导入索引时需要将要导入到solr中的汉字的编码方式转换成与solr一致的编码方式。