TermsResults termResults = results.Terms įoreach (TermsResult result in termResults)įoreach (KeyValuePair kvp in result.Terms)īasically I use the SolrNet parser and the connection code but not the query stuff. SolrQueryResults results = new SolrQueryResults()
ISolrAbstractResponseParser parser = >() String xml = connection.Get("/terms", termsParams) TermsParams.Add(new KeyValuePair("terms.sort", "count")) TermsParams.Add(new KeyValuePair("terms.prefix", mySearchString)) TermsParams.Add(new KeyValuePair("terms.fl", "name")) The source of the suggestions can be terms in a field in Solr, an external text file, or fields in other indexes. setting "qt" has no effect and either the default handler in SolrNet must be changed or the solr config needs to set handleSelect=true.) Here's how I solved this problem in my case: You use this feature to give users inline query suggestions based on other, similar terms. If you are running against a newer Solr server, this is most likely your problem. See, particularly the section on the old handleSelect=true behavior. then use your favorite XML parser to extractĪlternatively, instead of XML, the request can return a JSON response using the String response = solrConnection.Get(relativeUrl, parameters) Var solrConnection = new SolrConnection(solrUrl) String solrUrl = " string relativeUrl = "/suggest" Therefore, (similar to I went with making a web request and parsing out the suggested results from the XML web response. ) needs a mapped Solr document type and not a simple array of strings which the suggester provides. All the standard plumbing code from initializing the request ( Type with mappings is not compatible with a suggester results response. Hence, Cook's answer did not work for me.
It expects all mappings to occur with indexed Solr document results and not suggester results. Setting a handler in search explicitly overrides the searchhandler setting (if any). Request handler and does not currently support any other handler including The specific methods of pysolr’s Solr class (like morelikethis, suggestterms etc.) allow for a kwarg handler to override that value. Unfortunately, SolrNet seems to be built around the default I had the exact same requirement but could not find any way to easily handle Suggester results with SolrNet. I also dont see the suggestion list inside the results. And also the spellcheck in the results is also zero. Var results = solr.Query(keyword, options) Var solr = >() įilterQueries = new ISolrQuery New SolrBaseRepository.Instance().Start() My code to call the solrnet API looks as below I am able to get the suggestions from the url I have configured my solrconfig.xml and schema.xml to query for the suggestions. Here is the command I am using to fetch the result: This is the configuration from solrconfig file. Now I have configured the solr suggester in solrconfig.xml. I am running the solr in CloudSolr mode with three shards.