Package org.springframework.data.solr.core.query

Examples of org.springframework.data.solr.core.query.Criteria$Predicate


    int itemCount = (int) this.count();
    if (itemCount == 0) {
      return new PageImpl<T>(Collections.<T> emptyList());
    }
    return getSolrOperations().queryForPage(
        new SimpleQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD)).setPageRequest(
            new SolrPageRequest(0, itemCount)).addSort(sort), getEntityClass());
  }
View Full Code Here


            new SolrPageRequest(0, itemCount)).addSort(sort), getEntityClass());
  }

  @Override
  public Iterable<T> findAll(Iterable<ID> ids) {
    org.springframework.data.solr.core.query.Query query = new SimpleQuery(new Criteria(this.idFieldName).in(ids));
    query.setPageRequest(new SolrPageRequest(0, (int) count(query)));

    return getSolrOperations().queryForPage(query, getEntityClass());
  }
View Full Code Here

    return getSolrOperations().queryForPage(query, getEntityClass());
  }

  @Override
  public long count() {
    return count(new SimpleQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD)));
  }
View Full Code Here

  }

  @Override
  public void deleteAll() {
    registerTransactionSynchronisationIfSynchronisationActive();
    this.solrOperations.delete(new SimpleFilterQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD)));
    commitIfTransactionSynchronisationIsInactive();
  }
View Full Code Here

                .times(Long.valueOf(3)).build(), "{!func}product(foo(),field_1,bar(),3)" },
        {
            ProductFunction.product(new Foo()).times(new SimpleField("field_1")).times(new Bar())
                .times(Long.valueOf(3)).times(new SimpleField("field_2")).build(),
            "{!func}product(foo(),field_1,bar(),3,field_2)" },
        { QueryFunction.query(new Criteria("field_1").is("value")), "{!func}query(field_1:value)" },
        { QueryFunction.query(new SimpleQuery(new Criteria("field_1").is("value"))), "{!func}query(field_1:value)" },
        { TermFrequencyFunction.termFequency("term").inField(new SimpleField("field_1")),
            "{!func}termfreq(field_1,term)" },
        { TermFrequencyFunction.termFequency("term").inField("field_1"), "{!func}termfreq(field_1,term)" } };
    return Arrays.asList(data);
  }
View Full Code Here

    SolrDocumentList resultList = new SolrDocumentList();
    resultList.setNumFound(10);
    Mockito.when(responseMock.getResults()).thenReturn(resultList);
    Mockito.when(solrServerMock.query(Mockito.any(SolrQuery.class))).thenReturn(responseMock);

    long result = solrTemplate.count(new SimpleQuery(new Criteria("field_1").is("value1")));
    Assert.assertEquals(resultList.getNumFound(), result);

    Mockito.verify(solrServerMock, Mockito.times(1)).query(captor.capture());

    Assert.assertEquals(Integer.valueOf(0), captor.getValue().getStart());
View Full Code Here

    SolrDocumentList resultList = new SolrDocumentList();
    resultList.setNumFound(10);
    Mockito.when(responseMock.getResults()).thenReturn(resultList);
    Mockito.when(solrServerMock.query(Mockito.any(SolrQuery.class))).thenReturn(responseMock);

    Query query = new SimpleQuery(new Criteria("field_1").is("value1"));
    query.setPageRequest(new PageRequest(0, 5));
    long result = solrTemplate.count(query);
    Assert.assertEquals(resultList.getNumFound(), result);

    Mockito.verify(solrServerMock, Mockito.times(1)).query(captor.capture());
View Full Code Here

  @Test
  public void testBeanLifecycle() {
    ExampleSolrBean toInsert = createDefaultExampleBean();

    solrTemplate.saveBean(toInsert);
    ExampleSolrBean recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")),
        ExampleSolrBean.class);
    Assert.assertNull(recalled);
    solrTemplate.commit();

    recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")), ExampleSolrBean.class);
    Assert.assertEquals(toInsert.getId(), recalled.getId());

    solrTemplate.deleteById(toInsert.getId());
    recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")), ExampleSolrBean.class);
    Assert.assertEquals(toInsert.getId(), recalled.getId());

    solrTemplate.commit();
    recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")), ExampleSolrBean.class);
    Assert.assertNull(recalled);
  }
View Full Code Here

  @Test
  public void testRollback() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    solrTemplate.saveBean(toInsert);
    ExampleSolrBean recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")),
        ExampleSolrBean.class);
    Assert.assertNull(recalled);

    solrTemplate.rollback();
    recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")), ExampleSolrBean.class);
    Assert.assertNull(recalled);
  }
View Full Code Here

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField("name").addFacetOnField("id").setFacetLimit(5));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    for (Page<FacetFieldEntry> facetResultPage : page.getFacetResultPages()) {
View Full Code Here

TOP

Related Classes of org.springframework.data.solr.core.query.Criteria$Predicate

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.