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));
}
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);
}
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());
}
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());
}
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"));
}
Aggregations