use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerPojoTest method testRoundtrip2.
@Test
public void testRoundtrip2() {
final SearchServer server = searchServer.getSearchServer();
server.indexBean(new SimplePojo("1", "Hello World", 1, "hello"));
server.indexBean(new SimplePojo("2", "Hello Thomas", 2, "foo", "bar"));
server.commit();
BeanSearchResult<SimplePojo> result = server.execute(Search.fulltext().facet("voting", "category").sort(desc("voting")), SimplePojo.class);
assertNotNull(result);
assertEquals(1, result.getResults().get(0).getScoring(), 0);
// test suggestion
SuggestionResult suggestions = server.execute(Search.suggest("*").fields("category", "voting").filter("voting", "1"), SimplePojo.class);
assertEquals(1, suggestions.get("category").getValues().size());
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerPojoTest method testTaxonomyPojo.
@Test
public void testTaxonomyPojo() {
final SearchServer server = searchServer.getSearchServer();
final Pojo1 doc1 = new Pojo1();
doc1.id = "pojo-Id-1";
doc1.title = "title 1";
doc1.tax = new Taxonomy("term 1", 1, "", ZonedDateTime.now(), Arrays.asList("term 1", "term one"));
final Pojo1 doc2 = new Pojo1();
doc2.id = "pojo-Id-2";
doc2.title = "title 2";
doc2.tax = new Taxonomy("term 2", 2, "", ZonedDateTime.now(), Arrays.asList("term 2", "term two"));
server.indexBean(doc1);
server.indexBean(doc2);
server.commit();
final BeanSearchResult<Pojo1> second = server.execute(Search.fulltext("two"), Pojo1.class);
assertThat("#numOfResults", second.getNumOfResults(), CoreMatchers.equalTo(1l));
assertThat("results.size()", second.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), Pojo.class); //TODO create special sort for reserved fields (like score, type, id)
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());*/
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerPojoTest method testSearchGetById.
@Test
public void testSearchGetById() {
final SearchServer server = searchServer.getSearchServer();
server.indexBean(new SimplePojo("1", "Hello World", 1, "hello"));
server.indexBean(new SimplePojo("2", "Hello Thomas", 2, "foo", "bar"));
server.commit();
BeanGetResult<SimplePojo> result = server.execute(Search.getById("2"), SimplePojo.class);
assertEquals(1, result.getResults().size());
assertEquals("2", result.getResults().get(0).getId());
BeanGetResult<SimplePojo> multiResult = server.execute(Search.getById("1", "2", "42"), SimplePojo.class);
assertEquals(2, multiResult.getResults().size());
assertEquals("1", multiResult.getResults().get(0).getId());
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerPojoTest method testMultipleBeanIndex.
// MBDN-352
@Test
public void testMultipleBeanIndex() {
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("doc4", "Vier", "Das vierte Dokument", "complex");
server.indexBean(doc1, doc2);
List<Object> beanList = new ArrayList<>();
beanList.add(doc3);
beanList.add(doc4);
server.indexBean(beanList);
server.commit();
final BeanSearchResult<Pojo> all = server.execute(Search.fulltext(), Pojo.class);
assertThat("#numOfResults", all.getNumOfResults(), CoreMatchers.equalTo(4l));
assertThat("results.size()", all.getResults(), IsCollectionWithSize.hasSize(4));
checkPojo(doc3, all.getResults().get(2));
checkPojo(doc2, all.getResults().get(1));
checkPojo(doc1, all.getResults().get(0));
checkPojo(doc4, all.getResults().get(3));
}
use of com.rbmhtechnology.vind.api.SearchServer in project vind by RBMHTechnology.
the class TestServerTest method testSearchGetById.
@Test
public void testSearchGetById() {
SearchServer server = testSearchServer.getSearchServer();
MultiValueFieldDescriptor<String> term = new FieldDescriptorBuilder().setFullText(true).setFacet(true).buildMultivaluedTextField("term");
DocumentFactory factory = new DocumentFactoryBuilder("testDocFactory").addField(term).build();
server.index(factory.createDoc("1").setValue(term, "t1").addValue(term, "t2"));
server.index(factory.createDoc("2").setValue(term, "t2"));
server.index(factory.createDoc("21").setValue(term, "t2"));
server.index(factory.createDoc("42").setValue(term, "t42"));
server.commit();
GetResult result = server.execute(Search.getById("2"), factory);
assertEquals(1, result.getResults().size());
assertEquals("2", result.getResults().get(0).getId());
GetResult multiResult = server.execute(Search.getById("1", "2", "42"), factory);
assertEquals(3, multiResult.getResults().size());
assertEquals("1", multiResult.getResults().get(0).getId());
}
Aggregations