use of com.rbmhtechnology.vind.api.Document in project vind by RBMHTechnology.
the class TestServerTest method testSubdocumentFullReindex.
// MBDN-563
@Test
public void testSubdocumentFullReindex() throws IOException {
SearchServer server = testSearchServer.getSearchServer();
// SearchServer server = SolrSearchServer.getInstance("com.rbmhtechnology.searchlib.solr.RemoteSolrServerProvider","http://localhost:8983/solr","core");
server.clearIndex();
server.commit();
SingleValueFieldDescriptor<String> title = new FieldDescriptorBuilder().setFullText(true).setFacet(true).buildTextField("title");
SingleValueFieldDescriptor<String> color = new FieldDescriptorBuilder().setFullText(true).setFacet(true).setSuggest(true).buildTextField("color");
SingleValueFieldDescriptor<String> parent = new FieldDescriptorBuilder().setFacet(true).buildTextField("parent");
DocumentFactory asset = new DocumentFactoryBuilder("asset").setUpdatable(true).addField(title, color).build();
DocumentFactory marker = new DocumentFactoryBuilder("marker").setUpdatable(true).addField(title, color, parent).build();
Document a1 = asset.createDoc("A1").setValue(title, "A1 1").setValue(color, "blue");
Document a2 = asset.createDoc("A2").setValue(title, "A2").setValue(color, "red").addChild(marker.createDoc("M1").setValue(title, "M1").setValue(parent, "A2").setValue(color, "blue")).addChild(marker.createDoc("M4").setValue(title, "M4").setValue(parent, "A2").setValue(color, "green")).addChild(marker.createDoc("M5").setValue(title, "M5").setValue(parent, "A2").setValue(color, "yellow"));
Document a3 = asset.createDoc("A3").setValue(title, "A3").setValue(color, "green").addChild(marker.createDoc("M2").setValue(title, "M2").setValue(parent, "A3").setValue(color, "red"));
Document a4 = asset.createDoc("A4").setValue(title, "A4").setValue(color, "blue").addChild(marker.createDoc("M3").setValue(title, "M3").setValue(parent, "A4").setValue(color, "blue"));
server.index(a1);
server.index(a2);
server.index(a3);
server.index(a4);
server.commit();
// Test whether sub-documents are automatically removed from index when full indexing a parent document without them
a2.getChildren().clear();
a2.addChild(marker.createDoc("M6").setValue(title, "M6").setValue(parent, "A2").setValue(color, "purple"));
server.index(a2);
server.commit();
// search in all markers
final GetResult getM6child = server.execute(Search.getById("M6"), marker);
assertEquals("Subdocument with id:'M6' is indexed", 1, getM6child.getNumOfResults());
// search in all markers
final GetResult getM4child = server.execute(Search.getById("M4"), marker);
assertEquals("subdocument with id:'M4' is no more in the index", 0, getM4child.getNumOfResults());
// * The search UI displays the special facets "Assets" and "Markers" with according numbers matching the search criteria.
SearchResult result = server.execute(Search.fulltext().orChildrenSearch(marker).facet(type()), asset);
assertEquals("Asset Count", 4, result.getNumOfResults());
// TODO assertEquals("Facet Asset count",4,result.getFacetResults().getTypeFacet().getValues().get(0).getCount());
// TODO assertEquals("Facet Asset count",3,result.getFacetResults().getTypeFacet().getValues().get(1).getCount());
// * If the user selects the "Markers" facet only the assets with markers will be displayed.
result = server.execute(Search.fulltext().filter(hasChildrenDocuments(asset)), asset);
assertEquals("Only Assets with markers", 3, result.getNumOfResults());
// * No partial updates for markers yet (but likely to be requested, for example comments)
// Test behaviour of sub-documents when performing partial updates in children documents.
server.execute(Search.update("M6").set(title, "M6 seis"), marker);
server.commit();
result = server.execute(Search.fulltext().filter(eq(color, "purple", Scope.Suggest)).orChildrenSearch(marker), asset);
assertEquals("Nested document M6 is still linked to A2 parent document", 1, result.getNumOfResults());
// Test behabiour of sub-documents when full indexing a parent document after performing partial updates to
// children documents
a2.getChildren().clear();
a2.addChild(marker.createDoc("M6").setValue(title, "M6 seis").setValue(color, "purple"));
server.index(a2);
server.commit();
result = server.execute(Search.fulltext().filter(eq(color, "purple")).orChildrenSearch(marker), asset);
assertEquals("Nested document M6 is still linked to A2 parent document", 1, result.getNumOfResults());
// * Partial update are required for the asset.
assertEquals(1, server.execute(Search.getById("A2"), asset).getNumOfResults());
assertEquals(4, server.execute(Search.fulltext(), asset).getNumOfResults());
// Test behaviour of sub-documents when performing partial updates in parent documents.
server.execute(Search.update("A2").set(title, "A2 dos"), asset);
server.commit();
assertEquals(1, server.execute(Search.getById("A2"), asset).getNumOfResults());
// assertEquals(4, server.execute(Search.fulltext(),asset).getNumOfResults()); TODO!!
result = server.execute(Search.fulltext().filter(eq(color, "purple")).orChildrenSearch(marker), asset);
assertEquals("Nested document M6 is still linked to A2 parent document", 1, result.getNumOfResults());
// Test behabiour of sub-documents when full indexing a parent document after performing partial updates to
// parent documents
a2.setValue(title, "A2 dos");
server.index(a2);
server.commit();
result = server.execute(Search.fulltext().filter(eq(color, "purple")).orChildrenSearch(marker), asset);
assertEquals("Nested document M6 is still linked to A2 parent document", 1, result.getNumOfResults());
// * The search uses one index configuration for both. The field names for markers and assets are the same (for
// example a field "Person" of the asset is als available as "Person" on the Marker)
server.clearIndex();
server.commit();
}
use of com.rbmhtechnology.vind.api.Document in project vind by RBMHTechnology.
the class RESTMetadataProvider method getObject.
@Override
public <T> T getObject(T o) throws IOException {
DocumentFactory factory = AnnotationUtil.createDocumentFactory(o.getClass());
Document doc = AnnotationUtil.createDocument(o);
return AnnotationUtil.createPojo(getDocumentById(doc.getId(), factory), (Class<T>) o.getClass());
}
use of com.rbmhtechnology.vind.api.Document 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.api.Document in project vind by RBMHTechnology.
the class DocumentFactoryTest method addValueTest.
@Test
public void addValueTest() {
Document doc = factory.createDoc("idTest");
doc.addValue("multipleStringField", "0");
doc.addValue("multipleStringField", "4");
exception.expect(IllegalArgumentException.class);
doc.addValue("singleStringField", "5");
doc.addValue("multipleStringField", 4);
}
use of com.rbmhtechnology.vind.api.Document in project vind by RBMHTechnology.
the class AnnotationUtilTest method testCreatePojo1.
@Test
public void testCreatePojo1() throws Exception {
FieldDescriptor t = new FieldDescriptorBuilder().buildTextField("title");
FieldDescriptor c = new FieldDescriptorBuilder().buildTextField("data");
FieldDescriptor cats = new FieldDescriptorBuilder().buildMultivaluedTextField("cats");
FieldDescriptor tax = new ComplexFieldDescriptorBuilder<Taxonomy, String, String>().buildTextComplexField("tax", Taxonomy.class, String.class, String.class);
final DocumentFactoryBuilder docFactoryBuilder = new DocumentFactoryBuilder("Pojo");
docFactoryBuilder.addField(t).addField(c).addField(cats).addField(tax);
final DocumentFactory factory = docFactoryBuilder.build();
final Document doc = factory.createDoc("foo").setValue(t.getName(), "title").setValue(c.getName(), "content").setValues(cats.getName(), "cat1", "cat2", "cat3").setValue(tax, new Taxonomy("id-2", "term 2", Arrays.asList("term 2", "second term")));
final Pojo1 pojo = AnnotationUtil.createPojo(doc, Pojo1.class);
assertThat("id", pojo.id, equalTo("foo"));
assertThat("title", pojo.title, equalTo("title"));
assertThat("content", pojo.content, equalTo("content"));
assertThat("categories", pojo.categories, CoreMatchers.<Collection<String>>allOf(hasSize(3), containsInAnyOrder("cat1", "cat2", "cat3")));
}
Aggregations