简体   繁体   English

Solrj查询两个日期异常

[英]Solrj query two date exception

I use Apache Solr 4 and I new at Solr , I want to add last_modified by date chooser , but I get exception when I add some document which have own last_modified . 我使用Apache Solr 4而我在Solr新手,我想按date chooser添加last_modified ,但是当我添加一些具有last_modified文档时出现异常。 This exception I get. 我得到这个异常。 org.apache.solr.common.SolrException: Bad Request org.apache.solr.common.SolrException:错误的请求

I add field shema.xml las_date , but now i can't query range two date like this attr_las_date:[2013-01-00T20:00:00Z TO 2013-01-10T19:59:59Z] , because in schema.xml attr_ * format is String 我添加了字段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("*:*"));
}

How I add the date to documents? 如何将日期添加到文档中?

There should be 应该有

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

in your schema.xml 在您的schema.xml中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM