Solrj查询两个日期异常

时间:2013-01-09 13:16:42

标签: java solr solrj

我使用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("*:*"));
}

我如何将日期添加到文档?

1 个答案:

答案 0 :(得分:0)

应该有

<field name="las_date" type="date" indexed="true" stored="true"  />
在schema.xml中