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