lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <erik.hatc...@gmail.com>
Subject Re: Autocompletion with Solritas
Date Fri, 18 Jun 2010 09:05:39 GMT
Yup, that's basically what I've done too, here's the script part:
   <http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/velocity/layout.vm?view=markup

 >

I didn't touch the example solrconfig, though putting the params in  
the request handler is the better way, as you have.

	Erik


On Jun 18, 2010, at 3:32 AM, Chantal Ackermann wrote:

> Hi,
>
> here is my solution. It has been some time since I last looked at it,
> but it works fine. :-)
>
> <script type="text/javascript"
> src="/solr/epg/admin/file?file=/velocity/ 
> jquery-1.4.min.js&contentType=text/javascript"></script>
> <script type="text/javascript"
> src="/solr/epg/admin/file?file=/velocity/jquery- 
> ui.js&contentType=text/javascript"></script>
> <script type="text/javascript"
> src="/solr/epg/admin/file?file=/velocity/ 
> jquery.autocomplete.js&contentType=text/javascript"></script>
> <link rel="stylesheet" type="text/css"
> href="/solr/epg/admin/file?file=/velocity/ 
> jquery.autocomplete.css&contentType=text/css"/>
>
> <script type="text/javascript"
> src="/solr/epg/admin/file?file=/velocity/ 
> jquery.json-2.2.min.js&contentType=text/javascript"></script>
>
> $(function() {
> 	$("#qterm").autocomplete('/solr/epg/suggest', {
> 		extraParams: {
> 			'terms.prefix': function() { return $("#qterm").val(); }
> 		},
> 		hightlight: false,
> 		max: 30,
> 		formatItem: function(row, i, n) {
> 			return row;
> 		},
> 		parse: function(data) {
> 			var json =  jQuery.secureEvalJSON(data);
> 			var terms = json.terms;
> 			var suggMap = terms[1];
> 			var suggest = [];
> 			var j = 0;
> 			for (i=0; i<suggMap.length; i=i+2) {
> 				suggest[j] = {
> 					data: suggMap[i],
> 					value: suggMap[i],
> 					result: suggMap[i]
> 				}
> 				j = j+1;
> 			}
> 				
> 			return suggest;
> 		}
> 	});
> });
>
> #qterm is the form's input text field.
> in solrconfig.xml:
>
> 	<requestHandler name="/suggest" class="solr.SearchHandler" >
> 		<lst name="defaults">
> 			<str name="echoParams">explicit</str>
> 			<bool name="terms">true</bool>
> 			<bool name="terms.lower.incl">false</bool>
> 			<str name="wt">json</str>
> 			<str name="terms.fl">suggestsrc</str>
> 		</lst>
> 		<arr name="components">
> 			<str>terms</str>
> 		</arr>
> 	</requestHandler>
>
> suggestsrc is of type solr.TextField, accumulated from different  
> source
> fields.
>
> Cheers,
> Chantal
>


Mime
View raw message