Search in sources :

Example 1 with DocumentFactoryBuilder

use of com.rbmhtechnology.vind.model.DocumentFactoryBuilder in project vind by RBMHTechnology.

the class RESTMetadataProviderTest method testGetDocument2.

@Test
// ignored because of the username, password
@Ignore
public void testGetDocument2() throws IOException {
    MetadataProvider metadataProvider = new RESTMetadataProvider("https://mediamanager-staging.redbullmediahouse.com", "rbmh", "admin", "global", "1315204862832-1123067022", "asset", "user", "passw");
    SingleValueFieldDescriptor.TextFieldDescriptor<String> title = new FieldDescriptorBuilder().setFullText(true).setFacet(// notwendig für suggestion, da wirds noch ein setSuggestion(bool) geben
    true).putMetadata(RESTMetadataProvider.ID, "1319102420792-686346531").buildTextField("title");
    SingleValueFieldDescriptor.TextFieldDescriptor<String> description = new FieldDescriptorBuilder().setFullText(true).setFacet(// notwendig für suggestion, da wirds noch ein setSuggestion(bool) geben
    true).putMetadata(RESTMetadataProvider.ID, "1315204278582-8008411").buildTextField("description");
    DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(title, description).build();
    Document document = factory.createDoc("1359078847993-766700833");
    document = metadataProvider.getDocument(document, factory);
    Assert.assertEquals("Sean Pettit - Portrait", document.getValue(title));
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SingleValueFieldDescriptor(com.rbmhtechnology.vind.model.SingleValueFieldDescriptor) Document(com.rbmhtechnology.vind.api.Document) FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) DocumentFactoryBuilder(com.rbmhtechnology.vind.model.DocumentFactoryBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with DocumentFactoryBuilder

use of com.rbmhtechnology.vind.model.DocumentFactoryBuilder in project vind by RBMHTechnology.

the class SolrSearchServerTest method testExecute.

@Test
public void testExecute() throws Exception {
    Asset asset = new Asset();
    // FIXME: Asset has no @Id field
    server.indexBean(asset);
    // query
    BeanSearchResult<Asset> result = server.execute(Search.fulltext("hello world").filter(eq("category", "test")), Asset.class);
    // suggestion
    SuggestionResult suggestions = server.execute(Search.suggest("he").fields("category"), Asset.class);
    FieldDescriptor<String> title = new FieldDescriptorBuilder().setBoost(2).setLanguage(Language.German).buildTextField("title");
    // complex
    DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(title).build();
    Document document = factory.createDoc("1234");
    server.index(document);
    // suggestion
    SuggestionResult suggestionsFromFactory = server.execute(Search.suggest("he").fields("title"), factory);
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SuggestionResult(com.rbmhtechnology.vind.api.result.SuggestionResult) Asset(com.rbmhtechnology.vind.solr.backend.utils.Asset) Document(com.rbmhtechnology.vind.api.Document) FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) DocumentFactoryBuilder(com.rbmhtechnology.vind.model.DocumentFactoryBuilder) Test(org.junit.Test)

Example 3 with DocumentFactoryBuilder

use of com.rbmhtechnology.vind.model.DocumentFactoryBuilder in project vind by RBMHTechnology.

the class SolrSearchServerTest method testExecuteReal.

// is ignored because tests (and therefor requires) a remote solr server
@Test
@Ignore
public void testExecuteReal() throws Exception {
    SearchConfiguration.set(SearchConfiguration.SERVER_HOST, "http://localhost:8983/solr/searchindex");
    SearchServer server = SearchServer.getInstance();
    FieldDescriptor<String> title = new FieldDescriptorBuilder().setBoost(2).setLanguage(Language.German).buildTextField("title");
    DocumentFactory factory = new DocumentFactoryBuilder("asset").addField(title).build();
    server.index(factory.createDoc("1").setValue(title, "Hello World"));
    server.commit();
    assertEquals(1, server.execute(Search.fulltext(), factory).getNumOfResults());
}
Also used : DocumentFactory(com.rbmhtechnology.vind.model.DocumentFactory) SolrSearchServer(com.rbmhtechnology.vind.solr.backend.SolrSearchServer) SearchServer(com.rbmhtechnology.vind.api.SearchServer) FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) DocumentFactoryBuilder(com.rbmhtechnology.vind.model.DocumentFactoryBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with DocumentFactoryBuilder

use of com.rbmhtechnology.vind.model.DocumentFactoryBuilder 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)

Aggregations

DocumentFactory (com.rbmhtechnology.vind.model.DocumentFactory)4 DocumentFactoryBuilder (com.rbmhtechnology.vind.model.DocumentFactoryBuilder)4 FieldDescriptorBuilder (com.rbmhtechnology.vind.model.FieldDescriptorBuilder)4 Test (org.junit.Test)4 Document (com.rbmhtechnology.vind.api.Document)2 SingleValueFieldDescriptor (com.rbmhtechnology.vind.model.SingleValueFieldDescriptor)2 Ignore (org.junit.Ignore)2 SearchServer (com.rbmhtechnology.vind.api.SearchServer)1 SuggestionResult (com.rbmhtechnology.vind.api.result.SuggestionResult)1 FullTextEntry (com.rbmhtechnology.vind.monitoring.logger.entry.FullTextEntry)1 SimpleApplication (com.rbmhtechnology.vind.monitoring.model.application.SimpleApplication)1 SimpleSession (com.rbmhtechnology.vind.monitoring.model.session.SimpleSession)1 SolrSearchServer (com.rbmhtechnology.vind.solr.backend.SolrSearchServer)1 Asset (com.rbmhtechnology.vind.solr.backend.utils.Asset)1