use of org.apache.solr.schema.TrieDateField in project lucene-solr by apache.
the class AtomicUpdatesTest method testRemoveDateUsingDateType.
@Ignore("Remove Date is not supported in other formats than UTC")
@Test
public void testRemoveDateUsingDateType() throws Exception {
SolrInputDocument doc;
doc = new SolrInputDocument();
doc.setField("id", "10001");
TrieDateField trieDF = new TrieDateField();
Date tempDate = DateMathParser.parseMath(null, "2014-02-01T12:00:00Z");
doc.setField("dateRemove", new Date[] { DateMathParser.parseMath(null, "2014-02-01T12:00:00Z"), DateMathParser.parseMath(null, "2014-07-02T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-03T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-03T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-04T12:00:00Z") });
assertU(adoc(doc));
doc = new SolrInputDocument();
doc.setField("id", "10002");
doc.setField("dateRemove", new Date[] { DateMathParser.parseMath(null, "2014-02-01T12:00:00Z"), DateMathParser.parseMath(null, "2014-07-02T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-02T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-03T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-04T12:00:00Z") });
assertU(adoc(doc));
doc = new SolrInputDocument();
doc.setField("id", "10020");
doc.setField("dateRemove", new Date[] { DateMathParser.parseMath(null, "2014-02-01T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-03T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-04T12:00:00Z") });
assertU(adoc(doc));
doc = new SolrInputDocument();
doc.setField("id", "10021");
doc.setField("dateRemove", new Date[] { DateMathParser.parseMath(null, "2014-02-01T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-02T12:00:00Z"), DateMathParser.parseMath(null, "2014-02-04T12:00:00Z") });
assertU(adoc(doc));
assertU(commit());
assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
String dateString = DateMathParser.parseMath(null, "2014-02-02T12:00:00Z").toString();
// assertQ(req("q", "dateRemove:"+URLEncoder.encode(dateString, "UTF-8"), "indent", "true"), "//result[@numFound = '3']");
// assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
// assertQ(req("q", "dateRemove:"+dateString, "indent", "true"), "//result[@numFound = '3']"); //Sun Feb 02 10:00:00 FNT 2014
//Sun Feb 02 10:00:00 FNT 2014
assertQ(req("q", "dateRemove:\"Sun Feb 02 10:00:00 FNT 2014\"", "indent", "true"), "//result[@numFound = '3']");
doc = new SolrInputDocument();
doc.setField("id", "10001");
List<Date> removeList = new ArrayList<Date>();
removeList.add(DateMathParser.parseMath(null, "2014-09-02T12:00:00Z"));
removeList.add(DateMathParser.parseMath(null, "2014-09-03T12:00:00Z"));
//behavior when hitting Solr through ZK
doc.setField("dateRemove", ImmutableMap.of("remove", removeList));
assertU(adoc(doc));
assertU(commit());
assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '2']");
doc = new SolrInputDocument();
doc.setField("id", "10021");
removeList = new ArrayList<Date>();
removeList.add(DateMathParser.parseMath(null, "2014-09-02T12:00:00Z"));
removeList.add(DateMathParser.parseMath(null, "2014-09-03T12:00:00Z"));
//behavior when hitting Solr through ZK
doc.setField("dateRemove", ImmutableMap.of("remove", removeList));
assertU(adoc(doc));
assertU(commit());
assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '1']");
doc = new SolrInputDocument();
doc.setField("id", "10001");
//behavior when hitting Solr directly
doc.setField("dateRemove", ImmutableMap.of("remove", DateMathParser.parseMath(null, "2014-09-01T12:00:00Z")));
assertU(adoc(doc));
assertU(commit());
assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
assertQ(req("q", "dateRemove:\"2014-09-01T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
}
Aggregations