Solrj with Solr Suggester

前端 未结 3 1686
夕颜
夕颜 2021-01-12 23:06

What is the correct way of getting results from solrj using Solr Suggester?

This is my request:

SolrQuery query = new SolrQuery();
query.setRequestHa         


        
相关标签:
3条回答
  • 2021-01-12 23:27

    In new versions have a SuggesterResponse:

    https://lucene.apache.org/solr/5_3_1/solr-solrj/org/apache/solr/client/solrj/response/SuggesterResponse.html

    0 讨论(0)
  • 2021-01-12 23:35

    Best option is to get it as List, below code worked for me

        HttpSolrClient solrClient = new HttpSolrClient(solrURL);
        SolrQuery query = new SolrQuery();
        query.setRequestHandler("/suggest");
        query.setParam("suggest.q", "Ins");
        query.setParam("wt", "json");
        try {
    
            QueryResponse response = solrClient.query(query);
            System.out.println(response.getSuggesterResponse().getSuggestedTerms());
            List<String> types=response.getSuggesterResponse().getSuggestedTerms().get("infixSuggester");
            System.out.println(types);
        } catch (SolrServerException | IOException e) {
            e.printStackTrace();
        }
    
    0 讨论(0)
  • 2021-01-12 23:51

    You can get the suggestions via the SpellCheckResponse by doing the following

    SpellCheckResponse spellCheckResponse=response.getSpellCheckResponse();
    

    Check this link for more details

    0 讨论(0)
提交回复
热议问题