Search in sources :

Example 1 with FieldDescriptorBuilder

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

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

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

use of com.rbmhtechnology.vind.model.FieldDescriptorBuilder 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 5 with FieldDescriptorBuilder

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

the class SolrUtilsTest method testFieldNameConfiguration.

@Test
public void testFieldNameConfiguration() {
    FieldDescriptor facet = new FieldDescriptorBuilder().buildMultivaluedNumericField("test1");
    assertEquals("dynamic_multi_float_test1", SolrUtils.Fieldname.getFieldname(facet, SolrUtils.Fieldname.UseCase.Stored, null));
    assertEquals(2, SolrUtils.Fieldname.getFieldnames(facet, null).size());
    assertThat(SolrUtils.Fieldname.getFieldnames(facet, null), containsInAnyOrder("dynamic_multi_float_test1", "dynamic_single_sort_float_test1"));
    FieldDescriptor stored2 = new FieldDescriptorBuilder().setFacet(true).buildMultivaluedNumericField("test3", Integer.class);
    assertEquals("dynamic_multi_facet_int_test3", SolrUtils.Fieldname.getFieldname(stored2, SolrUtils.Fieldname.UseCase.Facet, null));
    assertEquals(3, SolrUtils.Fieldname.getFieldnames(stored2, null).size());
    assertThat(SolrUtils.Fieldname.getFieldnames(stored2, null), containsInAnyOrder("dynamic_multi_int_test3", "dynamic_multi_facet_int_test3", "dynamic_single_sort_int_test3"));
    FieldDescriptor mixed = new FieldDescriptorBuilder().setFullText(true).setFacet(true).buildMultivaluedTextField("test4");
    assertEquals("dynamic_multi_facet_string_test4", SolrUtils.Fieldname.getFieldname(mixed, SolrUtils.Fieldname.UseCase.Facet, null));
    assertEquals("dynamic_multi_string_test4", SolrUtils.Fieldname.getFieldname(mixed, SolrUtils.Fieldname.UseCase.Stored, null));
    assertEquals("dynamic_multi_none_test4", SolrUtils.Fieldname.getFieldname(mixed, SolrUtils.Fieldname.UseCase.Fulltext, null));
    assertEquals(4, SolrUtils.Fieldname.getFieldnames(mixed, null).size());
    assertThat(SolrUtils.Fieldname.getFieldnames(mixed, null), containsInAnyOrder("dynamic_single_sort_string_test4", "dynamic_multi_string_test4", "dynamic_multi_none_test4", "dynamic_multi_facet_string_test4"));
}
Also used : FieldDescriptorBuilder(com.rbmhtechnology.vind.model.FieldDescriptorBuilder) FieldDescriptor(com.rbmhtechnology.vind.model.FieldDescriptor) Test(org.junit.Test)

Aggregations

FieldDescriptorBuilder (com.rbmhtechnology.vind.model.FieldDescriptorBuilder)5 Test (org.junit.Test)5 DocumentFactory (com.rbmhtechnology.vind.model.DocumentFactory)4 DocumentFactoryBuilder (com.rbmhtechnology.vind.model.DocumentFactoryBuilder)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 FieldDescriptor (com.rbmhtechnology.vind.model.FieldDescriptor)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