Revision 7714
Added by Jing Tao about 11 years ago
HttpSolrQueryService.java | ||
---|---|---|
34 | 34 |
import java.util.Map; |
35 | 35 |
import java.util.Set; |
36 | 36 |
|
37 |
import org.apache.commons.logging.Log; |
|
38 |
import org.apache.commons.logging.LogFactory; |
|
37 | 39 |
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; |
38 |
import org.apache.solr.client.solrj.response.QueryResponse; |
|
40 |
|
|
39 | 41 |
import org.apache.solr.common.params.SolrParams; |
40 | 42 |
import org.apache.solr.schema.SchemaField; |
41 | 43 |
import org.dataone.cn.indexer.solrhttp.HTTPService; |
42 | 44 |
import org.dataone.cn.indexer.solrhttp.SolrDoc; |
43 | 45 |
import org.dataone.service.exceptions.NotFound; |
44 | 46 |
import org.dataone.service.exceptions.NotImplemented; |
45 |
import org.dataone.service.exceptions.UnsupportedType; |
|
46 | 47 |
import org.dataone.service.types.v1.Subject; |
47 | 48 |
|
48 |
import edu.ucsb.nceas.metacat.common.SolrQueryResponseTransformer; |
|
49 | 49 |
|
50 |
|
|
50 | 51 |
/** |
51 | 52 |
* The query service for the http solr server. |
52 | 53 |
* @author tao |
... | ... | |
56 | 57 |
|
57 | 58 |
private String solrServerBaseURL = null; |
58 | 59 |
private CommonsHttpSolrServer httpSolrServer = null; |
59 |
|
|
60 |
private static Log log = LogFactory.getLog(HttpSolrQueryService.class); |
|
60 | 61 |
/** |
61 | 62 |
* Constructor |
62 | 63 |
* @param httpSolrServer |
... | ... | |
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
/** |
73 |
* Query the Solr server with specified query and user's identity. If the Subjects |
|
74 |
* is null, there will be no access rules for the query. This is the for the http solr server. |
|
74 |
* Query the Solr server with specified query string and the user's identity. This is the for the http solr server. |
|
75 |
* It is hard to transform the SolrQueryReponse object to the InputStream object for the HttpSolrServer |
|
76 |
* since the transform needs the SolrCore. We have to open the solr url directly to get the InputStream. |
|
75 | 77 |
* @param query the query string |
76 | 78 |
* @param subjects the user's identity which sent the query |
77 | 79 |
* @return the response |
... | ... | |
87 | 89 |
} else { |
88 | 90 |
throw new NotFound("0000", "HttpSolrQueryService.query - There is no identity (even user public) for the user who issued the query"); |
89 | 91 |
} |
92 |
log.info("==========HttpSolrQueryService.query - the final url for querying the solr http server is "+query); |
|
90 | 93 |
URL url = new URL(query); |
94 |
|
|
91 | 95 |
return url.openStream(); |
92 | 96 |
} |
93 | 97 |
|
Also available in: Unified diff
Use one query method in the SolrQueryServiceController.