Solr suggester tutorial/simple example for java
I see some question about how to do specific things with Suggester in Solr, but how about how to actually use it? I'm stuck in how to simply query the suggest api to get the results in Java, maybe using Solrj? I just cannot find any simple tutorial that would explain it.
All I have is the SuggesterTest class that 开发者_如何学Ceven after 3hours of trying to decode I still cannot understand how things work, especially the crazy requests that look like:
req("qt", requestUri, "q", "ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
"//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']",
"//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[1][.='acquire']",
"//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[2][.='accommodate']"
Isn't there anything simpler than this?
Also, another question, do I need to rebuild the index for the suggestions? if let's say I added some data before, and now want to use them with suggester. Do I also need to specify somewhere which field I want to query in suggestions?
Thanks!
精彩评论