initial version of frontend layer
[opensuse:webpin2.git] / api / webpin.api / src / main / java / org / opensuse / webpin / api / FullTextQueryMethod.java
1 /*
2  * Created on Aug 3, 2010
3  */
4 package org.opensuse.webpin.api;
5
6 import java.util.List;
7
8 import org.apache.solr.client.solrj.SolrQuery;
9 import org.opensuse.webpin.api.SolrQueryRestlet.QueryMethod;
10 import org.restlet.Request;
11 import org.restlet.Response;
12
13 public class FullTextQueryMethod implements QueryMethod {
14     
15     private String searchTermAttributeName = "searchTerm";
16     
17         @Override public String configure(final Request request, final Response response, final SolrQueryRestlet rsc, final SolrQuery query, final List<String> filterQueries) {
18                 final String s = rsc.getStringAttribute(request, response, searchTermAttributeName); 
19                 //query.setQuery(String.format("{!lucene qf=name v=%s} {!lucene qf=name_rev v=*%s} {!dismax qf=text v=%s}", s, s, s));
20                 query.setQuery(String.format("{!lucene qf=name}%s~0.75^1000 %s", s, s));
21                 //System.out.println(query.toString());
22                 return s;
23         }
24         
25         public void setSearchTermAttributeName(String searchTermAttributeName) {
26         this.searchTermAttributeName = searchTermAttributeName;
27     }
28     
29 }