[英]Set field multivalued = false
When I execute a query with an order clause, the system throws an exception like this 当我使用order子句执行查询时,系统会引发类似这样的异常
cannot sort on multivalued field: DATE".
无法在多值字段上排序:DATE”。
this occurs with all fields types like string, long, etc. 所有字段类型(例如string,long等)都会发生这种情况
I analysed the fields with the Solr Schema Browser and all the fields have multivalue=true; 我使用Solr Schema Browser分析了这些字段,所有字段都具有multivalue = true; for the flags "properties" and "schema".
用于标记“属性”和“模式”。 (image atached
(图片已到达
)
)
I'm inserting the documents in this way whith java code: 我通过Java代码以这种方式插入文档:
String solrPath = Configuration.getString("solr.path");
HttpSolrClient solr = new HttpSolrClient(solrPath);
SolrInputDocument document = new SolrInputDocument();
document.addField("CATEGORY", knowError.getCategory().getDescription());
document.addField("RAITING", knowError.getRaiting()); //long value
document.addField("DATE", knowError.getRevisionDate());
UpdateRequest req = new UpdateRequest();
req.setAction(UpdateRequest.ACTION.COMMIT, false, false);
req.add(document);
UpdateResponse response = req.process(solr);
solr.commit();
And I make the querys in this way: 我以这种方式进行查询:
String solrPath = Configuration.getString("solr.path");
HttpSolrClient client = new HttpSolrClient(solrPath);
client.setUseMultiPartPost(true);
client.setConnectionTimeout(5000);
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(key);
solrQuery.setFields("KEDB_ID", "CAUSE", "SOLUTION", "WORKAROUND", "CATEGORY","DESCRIPTION","AUTHOR","TAGS","RAITING","DATE");
solrQuery.setStart(0);
solrQuery.setRows(200);
if(filterByRaiting){
solrQuery.addSort("RAITING", SolrQuery.ORDER.desc);
}else (filterByDate)
{
solrQuery.addSort("DATE", SolrQuery.ORDER.desc);
}
//solrQuery.addSort(SolrQuery.SortClause.asc("CAUSE"));
QueryResponse response = client.query(solrQuery);
ret= response.getResults();
How can I make the fields multivalue=false in the inserts? 如何在插入中使字段multivalue = false ?
Maybe you can define some dynamic fields
in your schema file before, like 也许您可以在架构文件中定义一些
dynamic fields
,例如
<dynamicField name="*_i" type="slong" indexed="true" stored="true" multiValued="false" />
and inserting the documents in this way whith java code: 并通过Java代码以这种方式插入文档:
document.addField("RAITING_i", knowError.getRaiting()); //long value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.