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

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


  public void testConstructSolrQueryWithSelectiveStatsFacet() {
    StatsOptions statsOptions = new StatsOptions()//
        .addField(new SimpleField("field_1"))//
        .addSelectiveFacet(new SimpleField("field_2"));

    SimpleQuery query = new SimpleQuery("*:*");
    query.setStatsOptions(statsOptions);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    String[] fields = solrQuery.getParams(StatsParams.STATS_FIELD);
    String[] facets = solrQuery.getParams(CommonParams.FIELD + ".field_1." + StatsParams.STATS_FACET);
View Full Code Here


    StatsOptions statsOptions = new StatsOptions()//
        .addField(new SimpleField("field_1")).setSelectiveCalcDistinct(true) //
        .addField(new SimpleField("field_2")).setSelectiveCalcDistinct(false) //
        .addField(new SimpleField("field_3"));

    SimpleQuery query = new SimpleQuery("*:*");
    query.setStatsOptions(statsOptions);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    String[] fields = solrQuery.getParams(StatsParams.STATS_FIELD);
    String[] calc1 = solrQuery.getParams(CommonParams.FIELD + ".field_1." + StatsParams.STATS_CALC_DISTINCT);
View Full Code Here

        .addSelectiveFacet(new SimpleField("field_1_1"))//
        .addSelectiveFacet(new SimpleField("field_1_2"))//
        .addField("field_2")//
        .addFacet("field_3");

    SimpleQuery query = new SimpleQuery("*:*");
    query.setStatsOptions(statsOptions);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    List<String> fields = Arrays.asList(solrQuery.getParams(StatsParams.STATS_FIELD));
    Collections.sort(fields);
View Full Code Here

   */
  @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"));
    groupOptions.addGroupByQuery(new SimpleQuery("*:*"));
    groupOptions.addSort(new Sort(Sort.Direction.DESC, "field_3"));
    groupOptions.setTotalCount(true);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

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);
    Assert.assertNull(solrQuery.get(GroupParams.GROUP_SORT));
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);

    assertGroupFormatPresent(solrQuery, false);
    Assert.assertArrayEquals(new String[] { "{!func}max(field_1,field_2)", "{!func}max(field_3,field_4)" },
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);

    assertGroupFormatPresent(solrQuery, false);
    Assert.assertArrayEquals(new String[] { "query1", "query2" }, solrQuery.getParams(GroupParams.GROUP_QUERY));
View Full Code Here

    BeanWithEnum loaded = saveAndLoad(bean);

    Assert.assertEquals(bean.id, loaded.id);
    Assert.assertEquals(bean.enumProperty, loaded.enumProperty);

    Query query = new SimpleQuery(new Criteria("enumProperty_s").is(LiteralNumberEnum.TWO));

    BeanWithEnum loadedViaProperty = solrTemplate.queryForObject(query, BeanWithEnum.class);
    Assert.assertEquals(bean.id, loadedViaProperty.id);
    Assert.assertEquals(bean.enumProperty, loadedViaProperty.enumProperty);
  }
View Full Code Here

  public void setUp() {
    this.template = new SolrTemplate(new HttpSolrServer("http://localhost:8983/solr"));
    template.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS));
    template.afterPropertiesSet();

    template.delete(new SimpleQuery("*:*"));
    template.commit();
  }
 
View Full Code Here

  @Test
  public void testConvertFacetQueryResponseForQueryResultWithNullFacetQueries() {
    Mockito.when(response.getFacetQuery()).thenReturn(null);
    List<FacetQueryEntry> result = ResultHelper.convertFacetQueryResponseToFacetQueryResult(
        createFacetQuery(new SimpleQuery(new SimpleStringCriteria("field_1:[* TO 5]"))), response);
    Assert.assertNotNull(result);
    Assert.assertTrue(result.isEmpty());
  }
View Full Code Here

TOP

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

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.