Search in sources :

Example 31 with FulltextSearch

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());
}
Also used : SearchResult(com.rbmhtechnology.vind.api.result.SearchResult) FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch) Test(org.junit.Test)

Example 32 with FulltextSearch

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());
}
Also used : SearchResult(com.rbmhtechnology.vind.api.result.SearchResult) FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch) Test(org.junit.Test)

Example 33 with FulltextSearch

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);
}
Also used : SearchResult(com.rbmhtechnology.vind.api.result.SearchResult) Update(com.rbmhtechnology.vind.api.query.update.Update) FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch) Test(org.junit.Test)

Example 34 with FulltextSearch

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);
}
Also used : FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch)

Example 35 with FulltextSearch

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);
}
Also used : FulltextSearch(com.rbmhtechnology.vind.api.query.FulltextSearch)

Aggregations

FulltextSearch (com.rbmhtechnology.vind.api.query.FulltextSearch)35 Test (org.junit.Test)31 SearchResult (com.rbmhtechnology.vind.api.result.SearchResult)26 SearchServer (com.rbmhtechnology.vind.api.SearchServer)21 Document (com.rbmhtechnology.vind.api.Document)20 SolrInputDocument (org.apache.solr.common.SolrInputDocument)20 ZonedDateTime (java.time.ZonedDateTime)11 PageResult (com.rbmhtechnology.vind.api.result.PageResult)8 MultiValueFieldDescriptor (com.rbmhtechnology.vind.model.MultiValueFieldDescriptor)8 Interval (com.rbmhtechnology.vind.api.query.facet.Interval)7 DateMathExpression (com.rbmhtechnology.vind.api.query.datemath.DateMathExpression)6 Delete (com.rbmhtechnology.vind.api.query.delete.Delete)6 SuggestionResult (com.rbmhtechnology.vind.api.result.SuggestionResult)6 LatLng (com.rbmhtechnology.vind.model.value.LatLng)5 ByteBuffer (java.nio.ByteBuffer)5 SolrClient (org.apache.solr.client.solrj.SolrClient)5 SolrQuery (org.apache.solr.client.solrj.SolrQuery)5 Language (com.rbmhtechnology.vind.annotations.language.Language)4 Search (com.rbmhtechnology.vind.api.query.Search)4 TimeUnit (com.rbmhtechnology.vind.api.query.datemath.DateMathExpression.TimeUnit)4