Package org.apache.solr.client.solrj.response

Examples of org.apache.solr.client.solrj.response.TermsResponse


      // exit if there is no terms
      if (terms == null) {
        return;
      }

      TermsResponse termsResponse = new TermsResponse(terms);
     
      // loop though each field and add each term+freq to map
      for (String key : fieldmap.keySet()) {
        HashMap<String, TermsResponse.Term> termmap = fieldmap.get(key);
        List<TermsResponse.Term> termlist = termsResponse.getTerms(key);

        // skip this field if there are no terms
        if (termlist == null) {
          continue;
        }
View Full Code Here


      // exit if there is no terms
      if (terms == null) {
        return;
      }

      TermsResponse termsResponse = new TermsResponse(terms);
     
      // loop though each field and add each term+freq to map
      for (String key : fieldmap.keySet()) {
        HashMap<String, TermsResponse.Term> termmap = fieldmap.get(key);
        List<TermsResponse.Term> termlist = termsResponse.getTerms(key);

        // skip this field if there are no terms
        if (termlist == null) {
          continue;
        }
View Full Code Here

  static Map<String, List<TermsFieldEntry>> convertTermsQueryResponseToTermsMap(QueryResponse response) {
    if (response == null || response.getTermsResponse() == null || response.getTermsResponse().getTermMap() == null) {
      return Collections.emptyMap();
    }

    TermsResponse termsResponse = response.getTermsResponse();
    Map<String, List<TermsFieldEntry>> result = new LinkedHashMap<String, List<TermsFieldEntry>>(termsResponse
        .getTermMap().size());

    for (Map.Entry<String, List<Term>> entry : termsResponse.getTermMap().entrySet()) {
      List<TermsFieldEntry> terms = new ArrayList<TermsFieldEntry>(entry.getValue().size());
      for (Term term : entry.getValue()) {
        SimpleTermsFieldEntry termsEntry = new SimpleTermsFieldEntry(term.getTerm(), term.getFrequency());
        termsEntry.setField(entry.getKey());
        terms.add(termsEntry);
View Full Code Here

  }

  @Test
  public void testConvertTermsQueryResponseReturnsTermsMapCorrectlyWhenOneFieldReturned() {
    TermsResponse termsResponse = new TermsResponse(new NamedList<NamedList<Number>>());
    termsResponse.getTermMap().put("field_1", Arrays.asList(new Term("term_1", 10), new Term("term_2", 5)));

    Mockito.when(response.getTermsResponse()).thenReturn(termsResponse);

    Map<String, List<TermsFieldEntry>> result = ResultHelper.convertTermsQueryResponseToTermsMap(response);
View Full Code Here

    Assert.assertEquals("field_1", result.get("field_1").get(1).getField().getName());
  }

  @Test
  public void testConvertTermsQueryResponseReturnsTermsMapCorrectlyWhenMultipleFieldsReturned() {
    TermsResponse termsResponse = new TermsResponse(new NamedList<NamedList<Number>>());
    termsResponse.getTermMap().put("field_1", Arrays.asList(new Term("term_1", 10), new Term("term_2", 5)));
    termsResponse.getTermMap().put("field_2", Arrays.asList(new Term("term_2", 2), new Term("term_3", 1)));

    Mockito.when(response.getTermsResponse()).thenReturn(termsResponse);

    Map<String, List<TermsFieldEntry>> result = ResultHelper.convertTermsQueryResponseToTermsMap(response);
View Full Code Here

        IsEqual.equalTo(Collections.<String, List<TermsFieldEntry>> emptyMap()));
  }

  @Test
  public void testConvertTermsQueryResponseReturnsEmtpyMapWhenTermsMapIsEmpty() {
    TermsResponse termsResponse = new TermsResponse(new NamedList<NamedList<Number>>());
    Mockito.when(response.getTermsResponse()).thenReturn(termsResponse);

    Assert.assertThat(ResultHelper.convertTermsQueryResponseToTermsMap(response),
        IsEqual.equalTo(Collections.<String, List<TermsFieldEntry>> emptyMap()));
  }
View Full Code Here

     * execute query and return terms, helper method
     */
    protected List<Term> executeQuery(SolrQuery q) throws NoOpenCoreException {
        try {
            Server solrServer = KeywordSearch.getServer();
            TermsResponse tr = solrServer.queryTerms(q);
            List<Term> termsCol = tr.getTerms(TERMS_SEARCH_FIELD);
            return termsCol;
        } catch (KeywordSearchModuleException ex) {
            logger.log(Level.WARNING, "Error executing the regex terms query: " + keyword.getQuery(), ex); //NON-NLS
            return null//no need to create result view, just display error dialog
        }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.response.TermsResponse

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.