doc.addField( "name", "my name!", 1.0f );
Assert.assertEquals( null, doc.getField("foo") );
Assert.assertTrue(doc.getField("name").getValue() != null );
UpdateResponse upres = server.add( doc );
System.out.println( "ADD:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
upres = server.commit( true, true );
System.out.println( "COMMIT:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
upres = server.optimize( true, true );
System.out.println( "OPTIMIZE:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
SolrQuery query = new SolrQuery();
query.setQuery( "id:"+docID );
QueryResponse response = server.query( query );
Assert.assertEquals(docID, response.getResults().get(0).getFieldValue("id") );
// Now add a few docs for facet testing...
List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField( "id", "2", 1.0f );
doc2.addField( "inStock", true, 1.0f );
doc2.addField( "price", 2, 1.0f );
doc2.addField( "timestamp_dt", new java.util.Date(), 1.0f );
docs.add(doc2);
SolrInputDocument doc3 = new SolrInputDocument();
doc3.addField( "id", "3", 1.0f );
doc3.addField( "inStock", false, 1.0f );
doc3.addField( "price", 3, 1.0f );
doc3.addField( "timestamp_dt", new java.util.Date(), 1.0f );
docs.add(doc3);
SolrInputDocument doc4 = new SolrInputDocument();
doc4.addField( "id", "4", 1.0f );
doc4.addField( "inStock", true, 1.0f );
doc4.addField( "price", 4, 1.0f );
doc4.addField( "timestamp_dt", new java.util.Date(), 1.0f );
docs.add(doc4);
SolrInputDocument doc5 = new SolrInputDocument();
doc5.addField( "id", "5", 1.0f );
doc5.addField( "inStock", false, 1.0f );
doc5.addField( "price", 5, 1.0f );
doc5.addField( "timestamp_dt", new java.util.Date(), 1.0f );
docs.add(doc5);
upres = server.add( docs );
System.out.println( "ADD:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
upres = server.commit( true, true );
System.out.println( "COMMIT:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
upres = server.optimize( true, true );
System.out.println( "OPTIMIZE:"+upres.getResponse() );
Assert.assertEquals(0, upres.getStatus());
query = new SolrQuery("*:*");
query.addFacetQuery("price:[* TO 2]");
query.addFacetQuery("price:[2 TO 4]");
query.addFacetQuery("price:[5 TO *]");