Search in sources :

Example 1 with SimpleApplication

use of com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication in project vind by RBMHTechnology.

the class MonitoringSearchServerTest method testSuggestionQueryMonitoringWithSessionAndLogger.

@Test
public void testSuggestionQueryMonitoringWithSessionAndLogger() throws IOException {
    TestMonitoringWriter logger = new TestMonitoringWriter();
    MonitoringSearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer(), new SimpleApplication("app"), new SimpleSession("123"), logger);
    final SingleValueFieldDescriptor.TextFieldDescriptor<String> textField = new FieldDescriptorBuilder<String>().setFacet(true).buildTextField("textField");
    final DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(textField).build();
    server.execute(Search.fulltext(), factory);
    server.setSession(new SimpleSession("456"));
    server.execute(Search.fulltext("Hello World").filter(or(eq(textField, "testFilter"), not(prefix("textField", "pref")))).facet(textField).sort(Sort.desc(textField)), factory);
    // logger.logs.get(1).toJson();
    assertEquals(2, logger.logs.size());
    assertEquals("app", ((SimpleApplication) logger.logs.get(0).getApplication()).getId());
    assertEquals("123", logger.logs.get(0).getSession().getSessionId());
    assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
    assertEquals("456", logger.logs.get(1).getSession().getSessionId());
    assertEquals("*", ((FullTextEntry) logger.logs.get(0)).getRequest().getQuery());
}
Also used : FullTextEntry(com.rbmhtechnology.vind.monitoring.logger.entry.FullTextEntry) DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SingleValueFieldDescriptor(com.rbmhtechnology.vind.model.SingleValueFieldDescriptor) SimpleApplication(com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication) SimpleSession(com.rbmhtechnology.vind.monitoring.model.session.SimpleSession) FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) DocumentFactoryBuilder(com.rbmhtechnology.vind.model.DocumentFactoryBuilder) Test(org.junit.Test)

Example 2 with SimpleApplication

use of com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication in project vind by RBMHTechnology.

the class MonitoringSearchServerTest method testQueryMonitoringWithSessionAndLogger.

@Test
public void testQueryMonitoringWithSessionAndLogger() throws IOException {
    TestMonitoringWriter logger = new TestMonitoringWriter();
    MonitoringSearchServer server = new MonitoringSearchServer(testSearchServer.getSearchServer(), new SimpleApplication("app"), new SimpleSession("123"), logger);
    // index 2 news items
    NewsItem i1 = new NewsItem("1", "New Vind instance needed", ZonedDateTime.now().minusMonths(3), "article", "coding");
    NewsItem i2 = new NewsItem("2", "Vind instance available", ZonedDateTime.now(), "blog", "coding", "release");
    server.indexBean(i1);
    server.indexBean(i2);
    server.commit();
    // this search should retrieve news items that should match the search term best
    FulltextSearch search = Search.fulltext("vind release");
    search.facet("category", "kind");
    BeanSearchResult<NewsItem> result = server.execute(search, NewsItem.class);
    assertEquals(1, logger.logs.size());
}
Also used : SimpleApplication(com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication) SimpleSession(com.rbmhtechnology.vind.monitoring.model.session.SimpleSession) FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch) NewsItem(com.rbmhtechnology.vind.monitoring.model.NewsItem) Test(org.junit.Test)

Aggregations

SimpleApplication (com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication)2 SimpleSession (com.rbmhtechnology.vind.monitoring.model.session.SimpleSession)2 Test (org.junit.Test)2 FulltextSearch (com.rbmhtechnology.vind.api.query.FulltextSearch)1 DocumentFactory (com.rbmhtechnology.vind.model.DocumentFactory)1 DocumentFactoryBuilder (com.rbmhtechnology.vind.model.DocumentFactoryBuilder)1 FieldDescriptorBuilder (com.rbmhtechnology.vind.model.FieldDescriptorBuilder)1 SingleValueFieldDescriptor (com.rbmhtechnology.vind.model.SingleValueFieldDescriptor)1 FullTextEntry (com.rbmhtechnology.vind.monitoring.logger.entry.FullTextEntry)1 NewsItem (com.rbmhtechnology.vind.monitoring.model.NewsItem)1