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

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


    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"));
    query.setHighlightOptions(new HighlightOptions());

    HighlightPage<ExampleSolrBean> page = solrTemplate.queryForHighlightPage(query, ExampleSolrBean.class);
    Assert.assertEquals(2, page.getHighlighted().size());
View Full Code Here


    Function f = IfFunction.when("inStock").then("1").otherwise("2");
    Query q1 = new SimpleQuery("cat:category2");
    Query q2 = new SimpleQuery("cat:category1");

    SimpleQuery groupQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
    GroupOptions groupOptions = new GroupOptions();
    groupQuery.setGroupOptions(groupOptions);
    groupOptions.addSort(new Sort("name", "id"));
    groupOptions.addGroupByField("name");
    groupOptions.addGroupByFunction(f);
View Full Code Here

    solrTemplate.saveBean(new ExampleSolrBean("id_4", "name2", "category2", 1, false));
    solrTemplate.saveBean(new ExampleSolrBean("id_5", "name2", "category2", 2, false));
    solrTemplate.saveBean(new ExampleSolrBean("id_6", "name2", "category1", 1, true));
    solrTemplate.commit();

    SimpleFacetQuery groupQuery = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    GroupOptions groupOptions = new GroupOptions();
    groupQuery.setGroupOptions(groupOptions);
    groupQuery.setFacetOptions(new FacetOptions("inStock"));
    groupOptions.addGroupByField("name");
    groupOptions.setGroupFacets(true);
View Full Code Here

    solrTemplate.commit();

    StatsOptions statsOptions = new StatsOptions().addField("popularity").addField("price")
        .setSelectiveCalcDistinct(true);

    SimpleQuery statsQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
    statsQuery.setStatsOptions(statsOptions);
    StatsPage<ExampleSolrBean> statResultPage = solrTemplate.queryForStatsPage(statsQuery, ExampleSolrBean.class);

    FieldStatsResult priceStatResult = statResultPage.getFieldStatsResult("price");
    FieldStatsResult popularityStatResult = statResultPage.getFieldStatsResult("popularity");
View Full Code Here

    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "two", null);
    bean2.setPrice(20.5f);
    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    SimpleQuery statsQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
    statsQuery.setStatsOptions(statsOptions);
    StatsPage<ExampleSolrBean> statResultPage = solrTemplate.queryForStatsPage(statsQuery, ExampleSolrBean.class);

    FieldStatsResult priceStats = statResultPage.getFieldStatsResult("price");
    Assert.assertEquals(Long.valueOf(2), priceStats.getCount());
View Full Code Here

      }

    };

    solrTemplate.registerQueryParser(SimpleQuery.class, parser);
    solrTemplate.query(new SimpleQuery(new SimpleStringCriteria("my:criteria")));

    ArgumentCaptor<SolrParams> captor = ArgumentCaptor.forClass(SolrParams.class);

    Mockito.verify(solrServerMock, Mockito.times(1)).query(captor.capture());
    Assert.assertEquals("*:*", captor.getValue().getParams(CommonParams.Q)[0]);
View Full Code Here

        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStringCriteria() {
    Criteria criteria = new SimpleStringCriteria("field_1:value_1 AND field_2:value_2");
    Assert.assertEquals("field_1:value_1 AND field_2:value_2", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:value_1 AND field_2:value_2", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStringCriteriaWithMoreFragments() {
    Criteria criteria = new SimpleStringCriteria("field_1:value_1 AND field_2:value_2");
    criteria = criteria.and("field_3").is("value_3");
    Assert.assertEquals("field_1:value_1 AND field_2:value_2 AND field_3:value_3",
        queryParser.createQueryStringFromNode(criteria));
  }
View Full Code Here

  }

  @Test
  public void testConstructSolrQueryWithSingleFacetFilterQuery() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetQuery(new SimpleQuery(new SimpleStringCriteria("field_2:[* TO 5]"))));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
View Full Code Here

  }

  @Test
  public void testConstructSolrQueryWithMultipleFacetFilterQuerues() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetQuery(new SimpleQuery(new SimpleStringCriteria("field_2:[* TO 5]"))).addFacetQuery(
            new SimpleQuery(new Criteria("field_3").startsWith("prefix"))));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
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.