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

Examples of org.springframework.data.solr.core.query.SimpleStringCriteria


  @Test
  public void testConstructGroupQueryWithAllPossibleParameters() {
    GroupOptions groupOptions = new GroupOptions();

    SimpleQuery query = new SimpleQuery();
    query.addCriteria(new SimpleStringCriteria("*:*"));
    query.setGroupOptions(groupOptions);
    groupOptions.setOffset(1);
    groupOptions.setLimit(2);
    groupOptions.addGroupByField("field_1");
    groupOptions.addGroupByFunction(MaxFunction.max("field_1", "field_2"));
View Full Code Here


   * @see DATASOLR-121
   */
  @Test
  public void testConstructGroupQueryWithoutPagingParameters() {
    SimpleQuery query = new SimpleQuery();
    query.addCriteria(new SimpleStringCriteria("*:*"));
    query.setGroupOptions(new GroupOptions().addGroupByField("fieldName"));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    assertGroupFormatPresent(solrQuery, false);
View Full Code Here

   * @see DATASOLR-121
   */
  @Test
  public void testConstructGroupQueryWithMultipleFunctions() {
    SimpleQuery query = new SimpleQuery();
    query.addCriteria(new SimpleStringCriteria("*:*"));
    query.setGroupOptions(new GroupOptions());
    query.getGroupOptions().addGroupByFunction(MaxFunction.max("field_1", "field_2"));
    query.getGroupOptions().addGroupByFunction(MaxFunction.max("field_3", "field_4"));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
View Full Code Here

   * @see DATASOLR-121
   */
  @Test
  public void testConstructGroupQueryWithMultipleQueries() {
    SimpleQuery query = new SimpleQuery();
    query.addCriteria(new SimpleStringCriteria("*:*"));
    query.setGroupOptions(new GroupOptions());
    query.getGroupOptions().addGroupByQuery(new SimpleQuery("query1"));
    query.getGroupOptions().addGroupByQuery(new SimpleQuery("query2"));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
View Full Code Here

    solrTemplate.commit();

    Assert.assertEquals(10, solrTemplate.count(ALL_DOCUMENTS_QUERY));

    Page<ExampleSolrBean> recalled = solrTemplate.queryForPage(
        new SimpleQuery(new SimpleStringCriteria("popularity:5")), ExampleSolrBean.class);

    Assert.assertEquals(5, recalled.getNumberOfElements());

    for (ExampleSolrBean bean : recalled) {
      Assert.assertEquals("Category must not change on partial update", "category_" + bean.getId(), bean.getCategory()
View Full Code Here

      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    q.setFacetOptions(new FacetOptions(new SimpleQuery(new SimpleStringCriteria("inStock:true")), new SimpleQuery(
        new SimpleStringCriteria("inStock:false"))));

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

    Page<FacetQueryEntry> facetQueryResultPage = page.getFacetQueryResult();
    Assert.assertEquals(2, facetQueryResultPage.getContent().size());
View Full Code Here

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    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);
View Full Code Here

      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++) {
View Full Code Here

      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("inStock:(true false)"));
    query.setDefaultOperator(Operator.AND);
    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);
    Assert.assertEquals(0, page.getContent().size());

    query.setDefaultOperator(Operator.OR);
View Full Code Here

    ipod.setManufacturerId(belkin.getId());

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

    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("text:ipod"));
    query.setJoin(Join.from("manu_id_s").to("id"));

    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);
    Assert.assertEquals(1, page.getContent().size());
    Assert.assertEquals(belkin.getId(), page.getContent().get(0).getId());
View Full Code Here

TOP

Related Classes of org.springframework.data.solr.core.query.SimpleStringCriteria

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.