Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.SearchResult


    query.withFulltext(text.toString());

    // Is it a page?
    Formatter formatter = null;
    try {
      SearchResult result = repository.find(query);

      // Format the output
      formatter = new Formatter(System.out);
      StringBuffer format = new StringBuffer();
      int padding = Long.toString(result.getDocumentCount()).length();
      format.append("%1$#").append(padding).append("s. %2$s\n");

      // List results
      int i = 1;
      for (SearchResultItem item : result.getItems()) {
        formatter.format(format.toString(), i++, item.getUrl());
      }

      System.out.println("Found " + result.getDocumentCount() + " results (" + result.getSearchTime() + " ms)");
    } catch (ContentRepositoryException e) {
      System.err.println("Error trying to access the content repository");
      e.printStackTrace(System.err);
    } finally {
      IOUtils.closeQuietly(formatter);
View Full Code Here


    // Make sure the search index is still consistent after an update. For this,
    // test one of the constructed fields that are not returned as part of the
    // search result and therefore are likely to be lost

    SearchQuery q = new SearchQueryImpl(site).withProperty(propertyName, propertyValue);
    SearchResult result = searchIdx.getByQuery(q);
    assertEquals(1, result.getDocumentCount());
    assertEquals(page.getURI().getIdentifier(), result.getItems()[0].getId());
  }
View Full Code Here

  @Test
  public void testGetWithAuthor() throws Exception {
    populateIndex();
    User amelie = new UserImpl("amelie");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withAuthor(amelie);
    SearchResult result = idx.getByQuery(q);
    assertEquals(pages.length, result.getDocumentCount());
    assertEquals(pages.length, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithCreator() throws Exception {
    populateIndex();
    User hans = new UserImpl("hans");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withCreator(hans);
    SearchResult result = idx.getByQuery(q);
    assertEquals(pages.length, result.getDocumentCount());
    assertEquals(pages.length, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithCreationDate() throws Exception {
    populateIndex();
    Date date = WebloungeDateFormat.parseStatic("2009-01-07T20:05:41Z");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withCreationDate(date);
    SearchResult result = idx.getByQuery(q);
    assertEquals(1, result.getDocumentCount());
    assertEquals(1, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithModifier() throws Exception {
    populateIndex();
    User amelie = new UserImpl("amelie");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withModifier(amelie);
    SearchResult result = idx.getByQuery(q);
    assertEquals(pages.length, result.getDocumentCount());
    assertEquals(pages.length, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithModificationDate() throws Exception {
    populateIndex();
    Date date = WebloungeDateFormat.parseStatic("2009-02-18T22:06:40Z");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withModificationDate(date);
    SearchResult result = idx.getByQuery(q);
    assertEquals(1, result.getDocumentCount());
    assertEquals(1, result.getDocumentCount());
  }
View Full Code Here

   */
  @Test
  public void testGetSortedByPublicationDate() throws Exception {
    populateIndex();
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).sortByPublishingDate(Order.Descending);
    SearchResult result = idx.getByQuery(q);
    assertEquals(pages.length, result.getDocumentCount());
    assertEquals(pages.length, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithPublisher() throws Exception {
    populateIndex();
    User amelie = new UserImpl("amelie");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPublisher(amelie);
    SearchResult result = idx.getByQuery(q);
    assertEquals(1, result.getDocumentCount());
    assertEquals(1, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testGetWithPublishingDate() throws Exception {
    populateIndex();
    Date date = WebloungeDateFormat.parseStatic("2006-05-05T17:58:21Z");
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPublishingDate(date);
    SearchResult result = idx.getByQuery(q);
    assertEquals(1, result.getDocumentCount());
    assertEquals(1, result.getDocumentCount());
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.SearchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.