我使用Apache Solr 4
而我是Solr
的新用户,我希望last_modified
添加date chooser
,但是当我添加一些拥有last_modified
的文档时,我会遇到异常1}}。这个例外我得到了。
org.apache.solr.common.SolrException:错误请求
我添加了字段shema.xml
las_date
,但现在我不能像这样查询范围两个日期
attr_las_date:[2013-01-00T20:00:00Z至2013-01-10T19:59:59Z]
,因为在schema.xml
attr _ *格式为String
public static void indexFilesSolrCell(String fileName, String solrId,String fileAuthor, String fileDate,String fileDescription, String fileTitle)
throws IOException, SolrServerException {
String urlString = "http://localhost:8983/solr";
SolrServer solr = new CommonsHttpSolrServer(urlString);
ContentStreamUpdateRequest up
= new ContentStreamUpdateRequest("/update/extract");
up.addFile(new File(fileName));
up.setParam("literal.id", solrId.replaceAll("\\s","").replaceAll("\\(","").replaceAll("\\)", ""));
up.setParam("literal.url", fileName);
up.setParam("literal.name", solrId);
up.setParam("literal.content_type",solrId);
up.setParam("uprefix", "attr_");
up.setParam("fmap.content", "content");
up.setParam("literal.owner",fileAuthor);
up.setParam("literal.last_modified", fileDate);
up.setParam("literal.description", fileDescription);
up.setParam("literal.title", fileTitle);
up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
solr.request(up);
QueryResponse rsp = solr.query(new SolrQuery("*:*"));
}
我如何将日期添加到文档?
答案 0 :(得分:0)
应该有
<field name="las_date" type="date" indexed="true" stored="true" />
在schema.xml中