Examples of ExampleSolrBean


Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(1, page.getAllFacets().size());
  }

  @Test
  public void testFacetQueryWithFacetPrefix() {
    ExampleSolrBean season = new ExampleSolrBean("1", "spring", "season");
    ExampleSolrBean framework = new ExampleSolrBean("2", "spring", "framework");
    ExampleSolrBean island = new ExampleSolrBean("3", "java", "island");
    ExampleSolrBean language = new ExampleSolrBean("4", "java", "language");

    solrTemplate.saveBeans(Arrays.asList(season, framework, island, language));
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    }
  }

  @Test
  public void testFacetQueryWithFieldFacetPrefix() {
    ExampleSolrBean season = new ExampleSolrBean("1", "spring", "season");
    ExampleSolrBean framework = new ExampleSolrBean("2", "spring", "framework");
    ExampleSolrBean island = new ExampleSolrBean("3", "java", "island");
    ExampleSolrBean language = new ExampleSolrBean("4", "java", "language");

    solrTemplate.saveBeans(Arrays.asList(season, framework, island, language));
    solrTemplate.commit();
    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spr"))
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    solrTemplate.commit();

    Query query = new SimpleQuery(new SimpleStringCriteria("*:*")).addSort(new Sort(Sort.Direction.DESC, "name"));
    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);

    ExampleSolrBean prev = page.getContent().get(0);
    for (int i = 1; i < page.getContent().size(); i++) {
      ExampleSolrBean cur = page.getContent().get(i);
      Assert.assertTrue(Long.valueOf(cur.getId()) < Long.valueOf(prev.getId()));
      prev = cur;
    }
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

  @Test
  public void testQueryWithMultiSort() {
    List<ExampleSolrBean> values = new ArrayList<ExampleSolrBean>();
    for (int i = 0; i < 10; i++) {
      ExampleSolrBean bean = createExampleBeanWithId(Integer.toString(i));
      bean.setInStock(i % 2 == 0);
      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    Query query = new SimpleQuery(new SimpleStringCriteria("*:*")).addSort(new Sort(Sort.Direction.DESC, "inStock"))
        .addSort(new Sort(Sort.Direction.ASC, "name"));
    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);

    ExampleSolrBean prev = page.getContent().get(0);
    for (int i = 1; i < 5; i++) {
      ExampleSolrBean cur = page.getContent().get(i);
      Assert.assertTrue(cur.isInStock());
      Assert.assertTrue(Long.valueOf(cur.getId()) > Long.valueOf(prev.getId()));
      prev = cur;
    }

    prev = page.getContent().get(5);
    for (int i = 6; i < page.getContent().size(); i++) {
      ExampleSolrBean cur = page.getContent().get(i);
      Assert.assertFalse(cur.isInStock());
      Assert.assertTrue(Long.valueOf(cur.getId()) > Long.valueOf(prev.getId()));
      prev = cur;
    }
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

  @Test
  public void testQueryWithDefaultOperator() {
    List<ExampleSolrBean> values = new ArrayList<ExampleSolrBean>();
    for (int i = 0; i < 10; i++) {
      ExampleSolrBean bean = createExampleBeanWithId(Integer.toString(i));
      bean.setInStock(i % 2 == 0);
      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals("rh-2", page.getContent().get(0).getId());
  }

  @Test
  public void testQueryWithJoinOperation() {
    ExampleSolrBean belkin = new ExampleSolrBean("belkin", "Belkin", null);
    ExampleSolrBean apple = new ExampleSolrBean("apple", "Apple", null);

    ExampleSolrBean ipod = new ExampleSolrBean("F8V7067-APL-KIT", "Belkin Mobile Power Cord for iPod", null);
    ipod.setManufacturerId(belkin.getId());

    solrTemplate.saveBeans(Arrays.asList(belkin, apple, ipod));
    solrTemplate.commit();

    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("text:ipod"));
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(belkin.getId(), page.getContent().get(0).getId());
  }

  @Test
  public void testQueryWithHighlights() {
    ExampleSolrBean belkin = new ExampleSolrBean("GB18030TEST", "Test with some GB18030TEST", null);
    ExampleSolrBean apple = new ExampleSolrBean("UTF8TEST", "Test with some UTF8TEST", null);

    solrTemplate.saveBeans(Arrays.asList(belkin, apple));
    solrTemplate.commit();

    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("name:with"));
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

  @Test
  public void testTermsQuery() {
    TermsQuery query = SimpleTermsQuery.queryBuilder().fields("name").build();

    ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one two three", null);
    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "two three", null);
    ExampleSolrBean bean3 = new ExampleSolrBean("id-3", "three", null);

    solrTemplate.saveBeans(Arrays.asList(bean1, bean2, bean3));
    solrTemplate.commit();

    TermsPage page = solrTemplate.queryForTermsPage(query);
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(1, values.get(2).getValueCount());
  }

  @Test
  public void testFuctionQueryInFilterReturnsProperResult() {
    ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "two", null);
    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    Query q = new SimpleQuery("*:*").addFilterQuery(new SimpleFilterQuery(new Criteria(QueryFunction
        .query("{!query v = 'one'}"))));
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertThat(result.getContent().get(0).getId(), IsEqual.equalTo(bean1.getId()));
  }

  @Test
  public void testFuctionQueryReturnsProperResult() {
    ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "two", null);
    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    Query q = new SimpleQuery(new Criteria(QueryFunction.query("{!query v='two'}")));

    Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
    Assert.assertThat(result.getContent().get(0).getId(), Is.is(bean2.getId()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.