@Test public void fieldsRequestsShouldTurnIntoSelectors() throws Exception, TException { String table = "fieldsRequestsShouldTurnIntoSelectors"; SolrServer server = TestTableCreator.newTable(table) .withRowCount(1) .withRecordsPerRow(2) .withRecordColumns("fam.value", "fam.mvf") .create(); SolrQuery query = new SolrQuery("value0-0"); query.setFields("fam.value"); QueryResponse response = server.query(query); assertEquals( "We should get our doc back for a valid test.", 1l, response.getResults().getNumFound()); SolrDocument docResult = response.getResults().get(0); assertEquals("value0-0", docResult.getFieldValue("fam.value")); assertNull( "We shouldn't get this one back since it wasnt in our fields.", docResult.getFieldValues("fam.mvf")); removeTable(table); }
@Test public void basicFullTextQuery() throws Exception { String table = "basicFullTextQuery"; SolrServer server = TestTableCreator.newTable(table) .withRowCount(1) .withRecordsPerRow(2) .withRecordColumns("fam.value", "fam.mvf", "fam.mvf") .create(); SolrQuery query = new SolrQuery("value0-0"); QueryResponse response = server.query(query); assertEquals("We should get our doc back.", 1l, response.getResults().getNumFound()); SolrDocument docResult = response.getResults().get(0); assertEquals("0", docResult.getFieldValue("recordid")); assertEquals("value0-0", docResult.getFieldValue("fam.value")); Collection<Object> mvfVals = docResult.getFieldValues("fam.mvf"); assertTrue( "We should get all our values back[" + mvfVals + "]", CollectionUtils.isEqualCollection(mvfVals, Lists.newArrayList("value0-0", "value0-0"))); removeTable(table); }
@Test public void documentsShouldBeAbleToBeIndexedInBatch() throws Exception, TException { String table = "multipleDocumentsShouldBeIndexed"; TestTableCreator.newTable(table) .withRowCount(100) .withRecordsPerRow(1) .withRecordColumns("fam.value") .create(); assertTotalResults(table, "fam.value:value0-0", 1l); assertTotalResults(table, "fam.value:value1-0", 1l); assertTotalResults(table, "rowid:1", 1l); assertTotalResults(table, "rowid:2", 1l); assertTotalResults(table, "fam.value:value99-0", 1l); assertTotalResults(table, "fam.value:justincase", 0l); removeTable(table); }
@Test public void childDocsShouldBecomeRecordsOfRow() throws Exception { String table = "childDocsShouldBecomeRecordsOfRow"; TestTableCreator.newTable(table) .withRowCount(1) .withRecordsPerRow(100) .withRecordColumns("fam.value") .create(); TableStats stats = client().tableStats(table); assertEquals("We should have one record.", 100, stats.recordCount); assertEquals("We should have one row.", 1, stats.rowCount); assertTotalResults(table, "fam.value:value0-0", 1l); assertTotalRecordResults(table, "recordid:99", 1l); removeTable(table); }
@Test public void weShouldBeAbleToDeleteARowById() throws Exception, TException { String table = "weShouldBeAbleToDeleteARowById"; SolrServer server = TestTableCreator.newTable(table) .withRowCount(2) .withRecordsPerRow(1) .withRecordColumns("fam.value") .create(); assertTotalResults(table, "rowid:0", 1l); assertTotalResults(table, "rowid:1", 1l); server.deleteById("1"); assertTotalResults(table, "rowid:0", 1l); assertTotalResults(table, "rowid:1", 0l); removeTable(table); }
@Test public void weShouldBeAbleToDeleteARowByAListOfIds() throws Exception, TException { String table = "weShouldBeAbleToDeleteARowByAListOfIds"; SolrServer server = TestTableCreator.newTable(table) .withRowCount(20) .withRecordsPerRow(1) .withRecordColumns("fam.value") .create(); assertTotalResults(table, "rowid:1", 1l); assertTotalResults(table, "rowid:2", 1l); List<String> ids = Lists.newArrayList("1", "2", "3", "4", "5"); server.deleteById(ids); for (String id : ids) { assertTotalResults(table, "rowid:" + id, 0l); } removeTable(table); }