1、
try {
CommonsHttpSolrServer("http://localhost:8983/solr");
2、
Collection docs = new ArrayList();
= list.get(i);
{
doc = new SolrInputDocument();
item.getId());
3、
String id;
void setId(String id) {
= id;
String getId() {
id;
Item(){
{
e) {
{
catch (Exception e) {
4、
{
e) {
e) {
5、
key, int start,
count, String[] sortfield, Boolean[] flag, Boolean hightlight) {
|| null == key || field.length != key.length) {
null;
|| null == flag || sortfield.length != flag.length) {
null;
= null;
= new SolrQuery(field[0] + ":" + key[0]);
(int i = 0; i < field.length; i++) {
+ ":" + key[i]);
i=0; i
(flag[i]) {
SolrQuery.ORDER.asc);
else {
SolrQuery.ORDER.desc);
(null != hightlight) {
// 开启高亮组件
e) {
= null;
= solr.query(query);
e) {
null;
t TO end],start与end是相应数据格式的值的字符串形式,“TO”
6、
= Search(field, key, 0, 10, sortfield, flag, true);
== rsp){
hightlight = rsp.getHighlighting();
tmpLists = rsp.getBeans(Item.class);
(int i = 0; i < tmpLists.size(); i++) {
hlString = hightlight.get(tmpLists.get(i).getId()).get("title").toString();
(null != hlString) {
7、
{
null;
= new StringBuffer("");
= new SolrQuery("*.*");
new QueryResponse();
= solr.query(query);
e) {
TODO: handle exception
null;
ff = rsp.getFacetField("title");
countList = ff.getValues();
== countList){
null;
i=0; i
tmp[] = countList.get(i).toString().split(" ");
2){
+ " ");
== 0){
= sb.toString().split(" ");
null;
二、总结
三、参考资料
1、
2、
3、
4、