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

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


        FacetQuery facetQuery = SimpleFacetQuery.fromQuery(query, new SimpleFacetQuery());
        facetQuery.setFacetOptions(extractFacetOptions(solrQueryMethod, accessor));
        return new FacetPageExecution(accessor.getPageable()).execute(facetQuery);
      }
      if (solrQueryMethod.isHighlightQuery()) {
        HighlightQuery highlightQuery = SimpleHighlightQuery.fromQuery(query, new SimpleHighlightQuery());
        highlightQuery.setHighlightOptions(extractHighlightOptions(solrQueryMethod, accessor));
        return new HighlightPageExecution(accessor.getPageable()).execute(highlightQuery);
      }
      return new PagedExecution(accessor.getPageable()).execute(query);
    } else if (solrQueryMethod.isCollectionQuery()) {
View Full Code Here


    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());

    Assert.assertEquals("name", page.getHighlighted().get(0).getHighlights().get(0).getField().getName());
View Full Code Here

    Assert.assertEquals("{!join from=inner_id to=outer_id}field_1:value_1", solrQuery.getQuery());
  }

  @Test
  public void testConstructSolrQueryWithEmptyHighlightOption() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    query.setHighlightOptions(new HighlightOptions());

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertTrue(solrQuery.getHighlight());
    Assert.assertArrayEquals(new String[] { Criteria.WILDCARD }, solrQuery.getHighlightFields());
  }
View Full Code Here

    Assert.assertArrayEquals(new String[] { Criteria.WILDCARD }, solrQuery.getHighlightFields());
  }

  @Test
  public void testConstructSolrQueryWithoutHighlightOption() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertFalse(solrQuery.getHighlight());
  }
View Full Code Here

    Assert.assertFalse(solrQuery.getHighlight());
  }

  @Test
  public void testConstructSolrQueryWithHighlightOptionHavingFields() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();
    options.addField("field_2", "field_3");
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertArrayEquals(new String[] { "field_2", "field_3" }, solrQuery.getHighlightFields());
  }
View Full Code Here

    Assert.assertArrayEquals(new String[] { "field_2", "field_3" }, solrQuery.getHighlightFields());
  }

  @Test
  public void testConstructSorlQueryWithHighlightOptionFragsize() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();
    options.setFragsize(10);
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals(options.getFragsize().intValue(), solrQuery.getHighlightFragsize());
  }
View Full Code Here

    Assert.assertEquals(options.getFragsize().intValue(), solrQuery.getHighlightFragsize());
  }

  @Test
  public void testConstructSorlQueryWithHighlightOptionFormatter() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();
    options.setFormatter("formatter");
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals(options.getFormatter(), solrQuery.getParams(HighlightParams.FORMATTER)[0]);
  }
View Full Code Here

    Assert.assertEquals(options.getFormatter(), solrQuery.getParams(HighlightParams.FORMATTER)[0]);
  }

  @Test
  public void testConstructSorlQueryWithHighlightOptionNrSnipplets() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();
    options.setNrSnipplets(10);
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals(options.getNrSnipplets().intValue(), solrQuery.getHighlightSnippets());
  }
View Full Code Here

    Assert.assertEquals(options.getNrSnipplets().intValue(), solrQuery.getHighlightSnippets());
  }

  @Test
  public void testConstructSorlQueryWithHighlightOptionsAndAnySolrParameter() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();
    options.addHighlightParameter(HighlightParams.SIMPLE_PRE, "{pre}");
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals(options.<String> getHighlightParameterValue(HighlightParams.SIMPLE_PRE),
        solrQuery.getHighlightSimplePre());
  }
View Full Code Here

        solrQuery.getHighlightSimplePre());
  }

  @Test
  public void testConstructSorlQueryWithFieldSpecificHighlightOptions() {
    SimpleHighlightQuery query = new SimpleHighlightQuery(new SimpleStringCriteria("field_1:value_1"));
    HighlightOptions options = new HighlightOptions();

    HighlightOptions.FieldWithHighlightParameters fieldWithHighlightParameters = new HighlightOptions.FieldWithHighlightParameters(
        "field_2");
    fieldWithHighlightParameters.setFormatter("formatter");
    fieldWithHighlightParameters.setFragsize(10);

    options.addField(fieldWithHighlightParameters);
    query.setHighlightOptions(options);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertArrayEquals(new String[] { "field_2" }, solrQuery.getHighlightFields());
    Assert.assertEquals(fieldWithHighlightParameters.getFormatter(),
        solrQuery.getParams("f.field_2." + HighlightParams.FORMATTER)[0]);
View Full Code Here

TOP

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

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.