0
votes

I'm stuck trying to figure out how to process autosuggest results using SolrJ. I have configured the solr.SuggestComponent within solrconfig.xml and am getting the expected result via the Solr Admin query tool. My result looks as follows:

{
  "responseHeader": {
    "status": 0,
    "QTime": 6
   },
  "suggest": {
    "mySuggester": {
      "re": {
        "numFound": 10,
        "suggestions": [
          {
            "term": "reviewed",
            "weight": 2841,
            "payload": ""
          },
          {
            "term": "references",
            "weight": 1880,
            "payload": ""
          },
          {
            "term": "related",
            "weight": 1462,
            "payload": ""
          }]
        }
      }
   }
}

I am using SolrJ within a Spring application to make the Solr request and process the response. I get the QueryResponse back populated, but cannot figure out a way to pull the "term"s out of the QueryResponse object so that they can be returned to the jsp. Any suggestions? I thought there should be some fairly simple way to pull these results out as there seems to be built in methods for other types of results such as search results (docs), facets, highlighting, spellchecker, etc. I'm new to Solr and may be missing the obvious solution. Thanks in advance for any help.

1

1 Answers

1
votes

I'm pretty sure you use SpellCheckComponent for your suggest (since looking here - https://wiki.apache.org/solr/Suggester)

So, it's pretty obvious that you need to use this method - http://lucene.apache.org/solr/4_10_0/solr-solrj/org/apache/solr/client/solrj/response/QueryResponse.html#getSpellCheckResponse()

Hope it helps.