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

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


      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().addFacetOnPivot("cat", "name"));

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

    List<FacetPivotFieldEntry> pivotEntries = page.getPivot("cat,name");
View Full Code Here


    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("name").setFacetLimit(5).setFacetPrefix("spr"));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);
    Page<FacetFieldEntry> facetPage = page.getFacetResultPage(new SimpleField("name"));
    for (FacetFieldEntry entry : facetPage) {
View Full Code Here

    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"))
            .addFacetOnField("cat").setFacetPrefix("lan").setFacetLimit(5));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);
    Page<FacetFieldEntry> facetPage = page.getFacetResultPage(new SimpleField("name"));
View Full Code Here

  public void testQueryWithDefType() {
    List<ExampleSolrBean> values = createBeansWithIdAndPrefix(5, "id-");
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    SimpleQuery query = new SimpleQuery(new Criteria("id").in("id-1", "id-2", "id-3"));
    query.setDefType("lucene");
    query.setDefaultOperator(Operator.OR);

    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);
    Assert.assertEquals(3, page.getContent().size());
View Full Code Here

    values.get(1).setInStock(true);

    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    SimpleQuery query = new SimpleQuery(new Criteria("id").in("rh-1", "rh-2"));
    Page<ExampleSolrBean> page = solrTemplate.queryForPage(query, ExampleSolrBean.class);
    Assert.assertEquals(2, page.getContent().size());

    query = new SimpleQuery(new Criteria("id").in("rh-1", "rh-2"));
    query.setRequestHandler("/instock");
    page = solrTemplate.queryForPage(query, ExampleSolrBean.class);
    Assert.assertEquals(1, page.getContent().size());
    Assert.assertEquals("rh-2", page.getContent().get(0).getId());
  }
View Full Code Here

    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'}"))));

    Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
    Assert.assertThat(result.getContent().get(0).getId(), IsEqual.equalTo(bean1.getId()));
  }
View Full Code Here

    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

  }

  @Test
  public void testConvertFacetQueryResponseForQueryWithoutFacetOptions() {
    Map<Field, Page<FacetFieldEntry>> result = ResultHelper.convertFacetQueryResponseToFacetPageMap(
        new SimpleFacetQuery(new Criteria("field_1")), null);
    Assert.assertNotNull(result);
    Assert.assertTrue(result.isEmpty());
  }
View Full Code Here

    fq.setFacetOptions(new FacetOptions(facetQueries));
    return fq;
  }

  private FacetQuery createFacetQuery(String... facetFields) {
    FacetQuery fq = new SimpleFacetQuery(new Criteria(facetFields[0]));
    fq.setFacetOptions(new FacetOptions(facetFields));
    return fq;
  }
View Full Code Here

    fq.setFacetOptions(new FacetOptions(facetFields));
    return fq;
  }

  private FacetQuery createFacetPivotQuery(String... pivotFieldNames) {
    FacetQuery fq = new SimpleFacetQuery(new Criteria("field_1"));
    fq.setFacetOptions(new FacetOptions().addFacetOnPivot(pivotFieldNames));
    return fq;
  }
View Full Code Here

TOP

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

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.