use of com.rbmhtechnology.vind.api.query.FulltextSearch in project vind by RBMHTechnology.
the class ParentChildrenTest method testSubdocumentFacetCountsFailure.
// MBDN-599
@Test
public void testSubdocumentFacetCountsFailure() {
FulltextSearch search = Search.fulltext().setStrict(false).filter(eq(shared_value, "red")).orChildrenSearch(child);
SearchResult result = server.execute(search, parent);
assertEquals(1, result.getFacetResults().getSubdocumentFacets().stream().findFirst().get().getChildrenCount());
assertEquals(1, (long) result.getFacetResults().getSubdocumentFacets().stream().findFirst().get().getParentCount());
search = Search.fulltext().setStrict(false).filter(or(eq(shared_value, "yellow"), eq(child_value, "red"))).orChildrenSearch(child);
result = server.execute(search, parent);
assertEquals(2, result.getFacetResults().getSubdocumentFacets().stream().findFirst().get().getChildrenCount());
assertEquals(1, (long) result.getFacetResults().getSubdocumentFacets().stream().findFirst().get().getParentCount());
}
use of com.rbmhtechnology.vind.api.query.FulltextSearch in project vind by RBMHTechnology.
the class ParentChildrenTest method testFilterOnlyWithParentValue.
@Test
public void testFilterOnlyWithParentValue() {
FulltextSearch search = Search.fulltext().setStrict(false).filter(eq(parent_value, "blue")).orChildrenSearch(child);
SearchResult result = server.execute(search, parent);
assertEquals(1, result.getNumOfResults());
assertEquals(Integer.valueOf(2), result.getResults().get(0).getChildCount());
}
use of com.rbmhtechnology.vind.api.query.FulltextSearch in project vind by RBMHTechnology.
the class ParentChildrenTest method testParentDuplicationOnAtomicUpdate.
// MBDN-579
@Test
public void testParentDuplicationOnAtomicUpdate() {
// Safe check: ensure the orChildren search works
FulltextSearch search = Search.fulltext().filter(eq(shared_value, "red")).orChildrenSearch(child);
SearchResult result = server.execute(search, parent);
assertEquals(2, result.getNumOfResults());
assertEquals(Integer.valueOf(1), result.getResults().get(1).getChildCount());
// Update parent document to pink
final Update updateToPink = Search.update("P2").set(parent_value, "pink");
server.execute(updateToPink, parent);
server.commit();
search = Search.fulltext().filter(eq(parent_value, "pink"));
result = server.execute(search, parent);
assertEquals(1, result.getNumOfResults());
// Safe check: ensure the orChildren search still works
search = Search.fulltext().filter(eq(shared_value, "red")).orChildrenSearch(child);
result = server.execute(search, parent);
assertEquals(2, result.getNumOfResults());
assertEquals(Integer.valueOf(1), result.getResults().get(1).getChildCount());
// ////////////////////////////////////
server.index(parent.createDoc("P2").setValue(parent_value, "blue").setValue(shared_value, "purple").addChild(child.createDoc("C1").setValue(child_value, "red").setValue(shared_value, "red"), child.createDoc("C2").setValue(child_value, "goblin-green").setValue(shared_value, "yellow")));
server.commit();
// ///////////////////////////////////
// Update parent document to neon-orange
final Update updateToNeonOrange = Search.update("P2").set(parent_value, "neon-orange");
server.execute(updateToNeonOrange, parent);
server.commit();
search = Search.fulltext().filter(eq(parent_value, "neon-orange"));
result = server.execute(search, parent);
assertEquals(1, result.getNumOfResults());
// Safe check: ensure the orChildren search still works
search = Search.fulltext().filter(eq(shared_value, "red")).orChildrenSearch(child);
result = server.execute(search, parent);
assertEquals(2, result.getNumOfResults());
assertEquals(Integer.valueOf(1), result.getResults().get(1).getChildCount());
server.index(parent.createDoc("P2").setValue(parent_value, "neon-yellow").setValue(shared_value, "purple").addChild(child.createDoc("C1").setValue(child_value, "red").setValue(shared_value, "red"), child.createDoc("C2").setValue(child_value, "blue").setValue(shared_value, "yellow")));
server.commit();
search = Search.fulltext().filter(eq(parent_value, "neon-yellow"));
result = server.execute(search, parent);
assertEquals(1, result.getNumOfResults());
// Safe check: ensure the orChildren search still works
search = Search.fulltext().filter(eq(shared_value, "red")).orChildrenSearch(child);
result = server.execute(search, parent);
assertEquals(2, result.getNumOfResults());
assertEquals(Integer.valueOf(1), result.getResults().get(1).getChildCount());
server.index(parent.createDoc("P2").setValue(parent_value, "neon-yellow").setValue(shared_value, "purple").addChild(child.createDoc("C0").setValue(child_value, "blue").setValue(shared_value, "yellow")));
server.commit();
assertEquals(1, 1);
}
use of com.rbmhtechnology.vind.api.query.FulltextSearch in project vind by RBMHTechnology.
the class SearchService method search.
public SearchResult search(String query, int raking) {
FulltextSearch search = Search.fulltext(query);
// ranking field is of type Integer, so only Integers are allowed here
search.filter(eq(ranking, raking));
// for the execution we now use the factory as parameter
return monitoringSearchServer.execute(search, newsItems);
}
use of com.rbmhtechnology.vind.api.query.FulltextSearch in project vind by RBMHTechnology.
the class SearchService method search.
public Object search(String query, int page, Sort sort) {
FulltextSearch search = Search.fulltext(query);
switch(sort) {
case date:
search.sort(desc(publicationDate));
break;
case score:
break;
case scoredate:
search.sort(desc(scoredDate(publicationDate)));
}
search.facet(category, kind);
search.page(page);
search.facet(range("published", publicationDate, ZonedDateTime.now().minus(Duration.ofDays(1)), ZonedDateTime.now(), Duration.ofHours(1)));
search.filter(publicationDate.between(ZonedDateTime.now().minusDays(7), ZonedDateTime.now()));
return monitoringSearchServer.execute(search, newsItems);
}
Aggregations