solr 自动提示

//solrconfig.xml
 
text_ik 
 
default 
name1 
true 
spellchecker 
 
 

 

 
suggest 
org.apache.solr.spelling.suggest.Suggester 
org.apache.solr.spelling.suggest.tst.TSTLookupFactory 
name1 
 
0.005 

true 



 
 
 
 
true 
suggest 
true 
10 
true 
 
 
suggest 
 
   


//java代码

String solrUrl = "http://localhost:8080/solr/ejavashopcore"; 
@Test 
public void testQuerySuggest() throws Exception { 
HttpSolrClient solrServer = new HttpSolrClient(solrUrl); 
SolrQuery solrQuery = new SolrQuery(); 
// solrQuery.set("q", "奶"); 
solrQuery.set("q", "name1:奶"); 
solrQuery.set("qt", "/suggest"); 
QueryResponse queryResponse = solrServer.query(solrQuery); 
SpellCheckResponse rsp = queryResponse.getSpellCheckResponse(); 
List rst = rsp.getSuggestions(); 
for(Suggestion sg:rst){ 
System.out.println(JSON.toJSONString(sg,true)); 
} 
}
solr 自动提示_第1张图片

你可能感兴趣的:(java,web开发)