Search in sources :

Example 46 with SearchServer

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());
}
Also used : SearchServer(com.rbmhtechnology.vind.api.SearchServer) SearchResult(com.rbmhtechnology.vind.api.result.SearchResult) Document(com.rbmhtechnology.vind.api.Document) SolrInputDocument(org.apache.solr.common.SolrInputDocument) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 47 with SearchServer

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

Example 48 with SearchServer

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

Example 49 with SearchServer

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

Example 50 with SearchServer

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());
}
Also used : 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