Search in sources :

Example 26 with SearchServer

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());
}
Also used : SuggestionResult(com.rbmhtechnology.vind.api.result.SuggestionResult) SearchServer(com.rbmhtechnology.vind.api.SearchServer) Test(org.junit.Test)

Example 27 with SearchServer

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());*/
}
Also used : SearchServer(com.rbmhtechnology.vind.api.SearchServer) Test(org.junit.Test)

Example 28 with SearchServer

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());
}
Also used : SearchServer(com.rbmhtechnology.vind.api.SearchServer) Test(org.junit.Test)

Example 29 with SearchServer

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));
}
Also used : SearchServer(com.rbmhtechnology.vind.api.SearchServer) Test(org.junit.Test)

Example 30 with SearchServer

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());
}
Also used : GetResult(com.rbmhtechnology.vind.api.result.GetResult) SearchServer(com.rbmhtechnology.vind.api.SearchServer) Test(org.junit.Test)

Aggregations

SearchServer (com.rbmhtechnology.vind.api.SearchServer)50 Test (org.junit.Test)46 SolrInputDocument (org.apache.solr.common.SolrInputDocument)31 Document (com.rbmhtechnology.vind.api.Document)30 SearchResult (com.rbmhtechnology.vind.api.result.SearchResult)28 FulltextSearch (com.rbmhtechnology.vind.api.query.FulltextSearch)24 ZonedDateTime (java.time.ZonedDateTime)16 SuggestionResult (com.rbmhtechnology.vind.api.result.SuggestionResult)13 MultiValueFieldDescriptor (com.rbmhtechnology.vind.model.MultiValueFieldDescriptor)12 PageResult (com.rbmhtechnology.vind.api.result.PageResult)11 Interval (com.rbmhtechnology.vind.api.query.facet.Interval)10 DateMathExpression (com.rbmhtechnology.vind.api.query.datemath.DateMathExpression)9 Delete (com.rbmhtechnology.vind.api.query.delete.Delete)9 GetResult (com.rbmhtechnology.vind.api.result.GetResult)9 LatLng (com.rbmhtechnology.vind.model.value.LatLng)8 ByteBuffer (java.nio.ByteBuffer)8 Language (com.rbmhtechnology.vind.annotations.language.Language)7 Search (com.rbmhtechnology.vind.api.query.Search)7 TimeUnit (com.rbmhtechnology.vind.api.query.datemath.DateMathExpression.TimeUnit)7 Facets (com.rbmhtechnology.vind.api.query.facet.Facets)7