Reputation: 339
I'm using JSP in implementing auto-complete using Solr, I'm using the following code in order to retrieve a list of terms:
SolrQuery query = new SolrQuery();
query.addTermsField("name_auto");
query.setTerms(true);
query.setTermsPrefix(TEXTFIELD VALUE);
...
I've to retrieve the list of terms based on the value of the text field (the Prefix)(ex:"k"), also, I've to update this list for each key press.
I followed this link: http://www.mattweber.org/2009/05/02/solr-autosuggest-with-termscomponent-and-jquery/
and I'm using those JQuery files: (it the same founded in Google library) http://jquery.com/
cause I tried this code but the problem is how can I write the URL so I can do a remote data source to my auto-Complete???
Thanks
Upvotes: 0
Views: 3720
Reputation: 339
Ok, Thank u all, I fix my prblem using JQueryUI files and tutorials, this my code:
$(function() {
$( MYTEXTFIELDNAME ).autocomplete({
source: function( request, response ) {
$.ajax({
url: 'http://localhost:8080/solr/terms?terms=true&terms.fl=MYAUTOFIELD&terms.prefix='
+request.term+'&wt=json',
dataType: "json",
data: {
style: "full",
maxRows: 5,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.terms.MYAUTOFIELD, function( item ) {
return {
label: item,
value: item,
}
}));
}
});
},
minLength: 1,
....
the remaining code is as described in http://jqueryui.com/demos/autocomplete/#remote
thanks again.
Upvotes: 2