0

我使用Apache Solr 4并且我是新的Solr,我想添加last_modifieddate chooser但是当我添加一些拥有自己的文档时出现异常last_modified。我得到了这个例外。org.apache.solr.common.SolrException:错误请求

我添加了字段shema.xml las_date,但现在我无法像这样查询范围两个日期 attr_las_date:[2013-01-00T20:00:00Z TO 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("*:*"));
}

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

4

1 回答 1

0

应该有

<field name="las_date" type="date" indexed="true" stored="true"  />

在你的 schema.xml

于 2013-01-09T15:00:36.647 回答