use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerTest method testPartialUpdate.
@Test
public void testPartialUpdate() {
SearchServer server = testSearchServer.getSearchServer();
SingleValueFieldDescriptor<String> title = new FieldDescriptorBuilder().setFullText(true).buildTextField("title");
SingleValueFieldDescriptor.DateFieldDescriptor<ZonedDateTime> created = new FieldDescriptorBuilder().setFacet(true).buildDateField("created");
NumericFieldDescriptor<Long> category = new FieldDescriptorBuilder().setFacet(true).buildMultivaluedNumericField("category", Long.class);
SingleValueFieldDescriptor.NumericFieldDescriptor<Integer> count = new FieldDescriptorBuilder().setFacet(true).buildNumericField("count", Integer.class);
DocumentFactory assets = new DocumentFactoryBuilder("asset").setUpdatable(true).addField(title, created, category, count).build();
ZonedDateTime now = ZonedDateTime.now();
Document d1 = assets.createDoc("123").setValue(title, "Hello World").setValue(count, 0).setValues(category, 1L, 2L, 3L).setValue(created, now);
server.index(d1);
server.commit();
server.execute(Search.update("123").set(title, "123").add(category, 6L, 10L).remove(created, now).removeRegex(category, "10").increment(count, 1), assets);
server.commit();
SearchResult result = server.execute(Search.fulltext("123"), assets);
assertEquals(1, result.getResults().size());
assertEquals("123", result.getResults().get(0).getValue("_id_"));
assertEquals("asset", result.getResults().get(0).getType());
server.execute(Search.update("123").remove(category).increment(count, -1), assets);
server.commit();
SearchResult result2 = server.execute(Search.fulltext(), assets);
assertEquals(1, result2.getResults().size());
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class SolrSearchServerTest method testConfigureCoreHostReal.
// is ignored because tests (and therefor requires) a remote solr server
@Test
@Ignore
public void testConfigureCoreHostReal() throws Exception {
SearchServer server = SearchServer.getInstance("http://localhost:8983/solr", "assets");
server.commit();
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class SolrSearchServerTest method testConfigureProviderHostCoreReal.
@Test
@Ignore
public void testConfigureProviderHostCoreReal() throws Exception {
SearchServer server = SearchServer.getInstance("RemoteSolrServerProvider", "http://localhost:8983/solr", "assets");
server.commit();
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class MonitoringSearchServerTest method testSuggestionQueryMonitoring.
@Test
public void testSuggestionQueryMonitoring() {
thrown.expect(RuntimeException.class);
final SearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer());
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerPojoTest method testPojoRoundtrip.
@Test
public void testPojoRoundtrip() {
final SearchServer server = searchServer.getSearchServer();
final Pojo doc1 = Pojo.create("doc1", "Eins", "Erstes Dokument", "simple");
final Pojo doc2 = Pojo.create("doc2", "Zwei", "Zweites Dokument", "simple");
final Pojo doc3 = Pojo.create("doc3", "Drei", "Dieses ist das dritte Dokument", "complex");
final Pojo doc4 = Pojo.create("doc3", "Drei", "Dieses ist das dritte Dokument", "complex");
server.indexBean(doc1);
server.indexBean(doc2);
server.indexBean(doc3);
server.commit();
final BeanSearchResult<Pojo> dritte = server.execute(Search.fulltext("dritte"), Pojo.class);
assertThat("#numOfResults", dritte.getNumOfResults(), CoreMatchers.equalTo(1l));
assertThat("results.size()", dritte.getResults(), IsCollectionWithSize.hasSize(1));
checkPojo(doc3, dritte.getResults().get(0));
final BeanSearchResult<Pojo> all = server.execute(Search.fulltext().facet("category").filter(or(eq("title", "Eins"), or(eq("title", "Zwei"), eq("title", "Drei")))).sort("_id_", Sort.Direction.Desc), // TODO create special sort for reserved fields (like score, type, id)
Pojo.class);
assertThat("#numOfResults", all.getNumOfResults(), CoreMatchers.equalTo(3l));
assertThat("results.size()", all.getResults(), IsCollectionWithSize.hasSize(3));
checkPojo(doc3, all.getResults().get(0));
checkPojo(doc2, all.getResults().get(1));
checkPojo(doc1, all.getResults().get(2));
TermFacetResult<String> facets = all.getFacetResults().getTermFacet("category", String.class);
assertEquals(2, facets.getValues().size());
assertEquals("simple", facets.getValues().get(0).getValue());
assertEquals("complex", facets.getValues().get(1).getValue());
assertEquals(2, facets.getValues().get(0).getCount());
assertEquals(1, facets.getValues().get(1).getCount());
}
Aggregations