使用SolrJ操作Solr会比利用httpClient来操作Solr要简单。SolrJ是封装了httpClient方法,来操作solr的API的。SolrJ底层还是通过使用httpClient中的方法来完成Solr的操作。

1、 首先,你需要添加如下jar包

其中apache-solr-solrj-3.4.0.jar、slf4j-api-1.6.1.jar可以在下载的apache-solr-3.4.0的压缩包中的dist中能找到。

2、 其次,建立一个简单的测试类,完成Server对象的相关方法的测试工作,代码如下:

package com.hoo.test;
 
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.hoo.entity.Index;
 
/**
 * <b>function:</b> Server TestCase
 * @author hoojo
 * @createDate 2011-10-19 下午01:49:07
 * @file ServerTest.java
 * @package com.hoo.test
 * @project SolrExample
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class ServerTest {
    
    private SolrServer server;
    private CommonsHttpSolrServer httpServer;
    
    private static final String DEFAULT_URL = "http://localhost:8983/solr/";
    
    @Before
    public void init() {
        try {
            server = new CommonsHttpSolrServer(DEFAULT_URL);
            httpServer = new CommonsHttpSolrServer(DEFAULT_URL);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    
    @After
    public void destory() {
        server = null;
        httpServer = null;
        System.runFinalization();
        System.gc();
    }
    
    public final void fail(Object o) {
        System.out.println(o);
    }
    
    /**
     * <b>function:</b> 测试是否创建server对象成功
     * @author hoojo
     * @createDate 2011-10-21 上午09:48:18
     */
    @Test
    public void server() {
        fail(server);
        fail(httpServer);
    }
 
    /**
     * <b>function:</b> 根据query参数查询索引
     * @author hoojo
     * @createDate 2011-10-21 上午10:06:39
     * @param query
     */
    public void query(String query) {
        SolrParams params = new SolrQuery(query);
        
        try {
            QueryResponse response = server.query(params);
            
            SolrDocumentList list = response.getResults();
            for (int i = 0; i < list.size(); i++) {
                fail(list.get(i));
            }
        } catch (SolrServerException e) {
            e.printStackTrace();
        } 
    }
}

测试运行server case方法,如果成功创建对象,那你就成功的链接到。

注意:在运行本方法之前,请启动你的solr官方自动的项目。http://localhost:8983/solr/保证能够成功访问这个工程。因为接下来的所有工作都是围绕这个solr工程完成的。如果你现在还不知道,怎么部署、发布官方solr工程,请参考前面的具体章节。

3、 Server的有关配置选项参数,server是CommonsHttpSolrServer的实例

server.setSoTimeout(1000); // socket read timeout 
server.setConnectionTimeout(100); 
server.setDefaultMaxConnectionsPerHost(100); 
server.setMaxTotalConnections(100); 
server.setFollowRedirects(false); // defaults to false 
// allowCompression defaults to false. 
// Server side must support gzip or deflate for this to have any effect. 
server.setAllowCompression(true); 
server.setMaxRetries(1); // defaults to 0.  > 1 not recommended. 
 
//sorlr J 目前使用二进制的格式作为默认的格式。对于solr1.2的用户通过显示的设置才能使用XML格式。
server.setParser(new XMLResponseParser());
 
//二进制流输出格式
//server.setRequestWriter(new BinaryRequestWriter());

4、 利用SolrJ完成Index Document的添加操作

/**
 * <b>function:</b> 添加doc文档
 * @author hoojo
 * @createDate 2011-10-21 上午09:49:10
 */
@Test
public void addDoc() {
    //创建doc文档
     SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", 1);
    doc.addField("name", "Solr Input Document");
    doc.addField("manu", "this is SolrInputDocument content");
    
    try {
        //添加一个doc文档
        UpdateResponse response = server.add(doc);
        fail(server.commit());//commit后才保存到索引库
        fail(response);
        fail("query time:" + response.getQTime());
        fail("Elapsed Time:" + response.getElapsedTime());
        fail("status:" + response.getStatus());
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    query("name:solr");
}

在apache-solr-3.4.0\example\solr\conf目录下的schema.xml中可以找到有关于field属性的配置,schema.xml中的field就和上面Document文档中的field(id、name、manu)对应。如果出现ERROR:unknown field 'xxxx'就表示你设置的这个field在schema.xml中不存在。如果一定要使用这个field,请你在schema.xml中进行filed元素的配置。具体请参考前面的章节。

注意:在schema.xml中配置了uniqueKey为id,就表示id是唯一的。如果在添加Document的时候,id重复添加。那么后面添加的相同id的doc会覆盖前面的doc,类似于update更新操作,而不会出现重复的数据。

5、 利用SolrJ添加多个Document,即添加文档集合

/**
 * <b>function:</b> 添加docs文档集合
 * @author hoojo
 * @createDate 2011-10-21 上午09:55:01
 */
@Test
public void addDocs() {
    Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
    
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", 2);
    doc.addField("name", "Solr Input Documents 1");
    doc.addField("manu", "this is SolrInputDocuments 1 content");
    
    docs.add(doc);
    
    doc = new SolrInputDocument();
    doc.addField("id", 3);
    doc.addField("name", "Solr Input Documents 2");
    doc.addField("manu", "this is SolrInputDocuments 3 content");
    
    docs.add(doc);
    
    try {
        //add docs
        UpdateResponse response = server.add(docs);
        //commit后才保存到索引库
        fail(server.commit());
        fail(response);
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    query("solr");
}

就是添加一个List集合

6、 添加JavaEntity Bean,这个需要先创建一个JavaBean,然后来完成添加操作;

JavaBean:Index的代码

package com.hoo.entity;
 
import org.apache.solr.client.solrj.beans.Field;
 
/**
 * <b>function:</b> JavaEntity Bean;Index需要添加相关的Annotation注解,便于告诉solr哪些属性参与到index中
 * @author hoojo
 * @createDate 2011-10-19 下午05:33:27
 * @file Index.java
 * @package com.hoo.entity
 * @project SolrExample
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class Index {
    //@Field setter方法上添加Annotation也是可以的
    private String id;
    @Field
    private String name;
    @Field
    private String manu;
    @Field
    private String[] cat;
 
    @Field
    private String[] features;
    @Field
    private float price;
    @Field
    private int popularity;
    @Field
    private boolean inStock;
    
    public String getId() {
        return id;
    }
    
    @Field
    public void setId(String id) {
        this.id = id;
    }
    //getter、setter方法
 
    public String toString() {
        return this.id + "#" + this.name + "#" + this.manu + "#" + this.cat;
    }
}

注意上面的属性是和在apache-solr-3.4.0\example\solr\conf目录下的schema.xml中可以找到有关于field属性的配置对应的。如果你Index JavaBean中出现的属性在schema.xml的field配置无法找到,那么出出现unknown filed错误。

添加Bean完成doc添加操作

/**
 * <b>function:</b> 添加JavaEntity Bean
 * @author hoojo
 * @createDate 2011-10-21 上午09:55:37
 */
@Test
public void addBean() {
    //Index需要添加相关的Annotation注解,便于告诉solr哪些属性参与到index中
    Index index = new Index();
    index.setId("4");
    index.setName("add bean index");
    index.setManu("index bean manu");
    index.setCat(new String[] { "a1", "b2" });
    
    try {
        //添加Index Bean到索引库
        UpdateResponse response = server.addBean(index);
        fail(server.commit());//commit后才保存到索引库
        fail(response);
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    queryAll();
}

7、 添加Bean集合

/**
 * <b>function:</b> 添加Entity Bean集合到索引库
 * @author hoojo
 * @createDate 2011-10-21 上午10:00:55
 */
@Test
public void addBeans() {
    Index index = new Index();
    index.setId("6");
    index.setName("add beans index 1");
    index.setManu("index beans manu 1");
    index.setCat(new String[] { "a", "b" });
    
    List<Index> indexs = new ArrayList<Index>();
    indexs.add(index);
    
    index = new Index();
    index.setId("5");
    index.setName("add beans index 2");
    index.setManu("index beans manu 2");
    index.setCat(new String[] { "aaa", "bbbb" });
    indexs.add(index);
    try {
        //添加索引库
        UpdateResponse response = server.addBeans(indexs);
        fail(server.commit());//commit后才保存到索引库
        fail(response);
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    queryAll();
}

8、 删除索引Document

/**
 * <b>function:</b> 删除索引操作
 * @author hoojo
 * @createDate 2011-10-21 上午10:04:28
 */
@Test
public void remove() {
    try {
        //删除id为1的索引
        server.deleteById("1");
        server.commit();
        query("id:1");
        
        //根据id集合,删除多个索引
        List<String> ids = new ArrayList<String>();
        ids.add("2");
        ids.add("3");
        server.deleteById(ids);
        server.commit(true, true);
        query("id:3 id:2");
        
        //删除查询到的索引信息
        server.deleteByQuery("id:4 id:6");
        server.commit(true, true);
        queryAll();
        
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

9、 查询索引

/**
 * <b>function:</b> 查询所有索引信息
 * @author hoojo
 * @createDate 2011-10-21 上午10:05:38
 */
@Test
public void queryAll() {
    ModifiableSolrParams params = new ModifiableSolrParams();
    // 查询关键词,*:*代表所有属性、所有值,即所有index
    params.set("q", "*:*");
    // 分页,start=0就是从0开始,,rows=5当前返回5条记录,第二页就是变化start这个值为5就可以了。
    params.set("start", 0);
    params.set("rows", Integer.MAX_VALUE);
    
    // 排序,,如果按照id 排序,,那么将score desc 改成 id desc(or asc)
    params.set("sort", "score desc");
 
    // 返回信息 * 为全部 这里是全部加上score,如果不加下面就不能使用score
    params.set("fl", "*,score");
    
    try {
        QueryResponse response = server.query(params);
        
        SolrDocumentList list = response.getResults();
        for (int i = 0; i < list.size(); i++) {
            fail(list.get(i));
        }
    } catch (SolrServerException e) {
        e.printStackTrace();
    }
}

10、 其他和Server有关方法

/**
 * <b>function:</b> 其他server相关方法测试
 * @author hoojo
 * @createDate 2011-10-21 上午10:02:03
 */
@Test
public void otherMethod() {
    fail(server.getBinder());
    try {
        fail(server.optimize());//合并索引文件,可以优化索引、提供性能,但需要一定的时间
        fail(server.ping());//ping服务器是否连接成功
        
        Index index = new Index();
        index.setId("299");
        index.setName("add bean index199");
        index.setManu("index bean manu199");
        index.setCat(new String[] { "a199", "b199" });
        
        UpdateResponse response = server.addBean(index);
        fail("response: " + response);
        
        queryAll();
        //回滚掉之前的操作,rollback addBean operation
        fail("rollback: " + server.rollback());
        //提交操作,提交后无法回滚之前操作;发现addBean没有成功添加索引
        fail("commit: " + server.commit());
        queryAll();
    } catch (SolrServerException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

11、 文档查询

/**
 * <b>function:</b> query 基本用法测试
 * @author hoojo
 * @createDate 2011-10-20 下午04:44:28
 */
@Test
public void queryCase() {
    //AND 并且
    SolrQuery params = new SolrQuery("name:apple AND manu:inc");
    
    //OR 或者
    params.setQuery("name:apple OR manu:apache");
    //空格 等同于 OR
    params.setQuery("name:server manu:dell");
    
    //params.setQuery("name:solr - manu:inc");
    //params.setQuery("name:server + manu:dell");
    
    //查询name包含solr apple
    params.setQuery("name:solr,apple");
    //manu不包含inc
    params.setQuery("name:solr,apple NOT manu:inc");
    
    //50 <= price <= 200
    params.setQuery("price:[50 TO 200]");
    params.setQuery("popularity:[5 TO 6]");
    //params.setQuery("price:[50 TO 200] - popularity:[5 TO 6]");
    //params.setQuery("price:[50 TO 200] + popularity:[5 TO 6]");
    
    //50 <= price <= 200 AND 5 <= popularity <= 6
    params.setQuery("price:[50 TO 200] AND popularity:[5 TO 6]");
    params.setQuery("price:[50 TO 200] OR popularity:[5 TO 6]");
    
    //过滤器查询,可以提高性能 filter 类似多个条件组合,如and
    //params.addFilterQuery("id:VA902B");
    //params.addFilterQuery("price:[50 TO 200]");
    //params.addFilterQuery("popularity:[* TO 5]");
    //params.addFilterQuery("weight:*");
    //0 < popularity < 6  没有等于
    //params.addFilterQuery("popularity:{0 TO 6}");
    
    //排序
    params.addSortField("id", ORDER.asc);
    
    //分页:start开始页,rows每页显示记录条数
    //params.add("start", "0");
    //params.add("rows", "200");
    //params.setStart(0);
    //params.setRows(200);
    
    //设置高亮
    params.setHighlight(true); // 开启高亮组件
    params.addHighlightField("name");// 高亮字段
    params.setHighlightSimplePre("<font color='red'>");//标记,高亮关键字前缀
    params.setHighlightSimplePost("</font>");//后缀
    params.setHighlightSnippets(1);//结果分片数,默认为1
    params.setHighlightFragsize(1000);//每个分片的最大长度,默认为100
 
    //分片信息
    params.setFacet(true)
        .setFacetMinCount(1)
        .setFacetLimit(5)//段
        .addFacetField("name")//分片字段
        .addFacetField("inStock"); 
    
    //params.setQueryType("");
    
    try {
        QueryResponse response = server.query(params);
        
        /*List<Index> indexs = response.getBeans(Index.class);
        for (int i = 0; i < indexs.size(); i++) {
            fail(indexs.get(i));
        }*/
        
        //输出查询结果集
        SolrDocumentList list = response.getResults();
        fail("query result nums: " + list.getNumFound());
        for (int i = 0; i < list.size(); i++) {
            fail(list.get(i));
        }
        
        //输出分片信息
        List<FacetField> facets = response.getFacetFields();
        for (FacetField facet : facets) {
            fail(facet);
            List<Count> facetCounts = facet.getValues();
            for (FacetField.Count count : facetCounts) {
                System.out.println(count.getName() + ": " + count.getCount());
            }
        }
    } catch (SolrServerException e) {
        e.printStackTrace();
    } 
}

12、 分片查询、统计

/**
 * <b>function:</b> 分片查询, 可以统计关键字及出现的次数、或是做自动补全提示
 * @author hoojo
 * @createDate 2011-10-20 下午04:54:25
 */
@Test
public void facetQueryCase() {
    SolrQuery params = new SolrQuery("*:*");
    
    //排序
    params.addSortField("id", ORDER.asc);
    
    params.setStart(0);
    params.setRows(200);
 
    //Facet为solr中的层次分类查询
    //分片信息
    params.setFacet(true)
        .setQuery("*:*")
        .setFacetMinCount(1)
        .setFacetLimit(5)//段
        //.setFacetPrefix("electronics", "cat")
        .setFacetPrefix("cor")//查询manu、name中关键字前缀是cor的
        .addFacetField("manu")
        .addFacetField("name");//分片字段
 
    try {
        QueryResponse response = server.query(params);
        
        //输出查询结果集
        SolrDocumentList list = response.getResults();
        fail("Query result nums: " + list.getNumFound());
        
        for (int i = 0; i < list.size(); i++) {
            fail(list.get(i));
        }
        
        fail("All facet filed result: ");
        //输出分片信息
        List<FacetField> facets = response.getFacetFields();
        for (FacetField facet : facets) {
            fail(facet);
            List<Count> facetCounts = facet.getValues();
            for (FacetField.Count count : facetCounts) {
                //关键字 - 出现次数
                fail(count.getName() + ": " + count.getCount());
            }
        }
        
        fail("Search facet [name] filed result: ");
        //输出分片信息
        FacetField facetField = response.getFacetField("name");
        List<Count> facetFields = facetField.getValues();
        for (Count count : facetFields) {
            //关键字 - 出现次数
            fail(count.getName() + ": " + count.getCount());
        }
    } catch (SolrServerException e) {
        e.printStackTrace();
    } 
}

分片查询在某些统计关键字的时候还是很有用的,可以统计关键字出现的次数,可以通过统计的关键字来搜索相关文档的信息。

13、Document文档和JavaBean相互转换

这里转换的Bean是一个简单的User对象

package com.hoo.entity;
 
import java.io.Serializable;
import org.apache.solr.client.solrj.beans.Field;
 
/**
 * <b>function:</b> User Entity Bean;所有被添加Annotation @Field 注解的属性将参与index操作
 * @author hoojo
 * @createDate 2011-10-19 下午04:16:00
 * @file User.java
 * @package com.hoo.entity
 * @project SolrExample
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class User implements Serializable {
 
    /**
     * @author Hoojo
     */
    private static final long serialVersionUID = 8606788203814942679L;
 
    //@Field
    private int id;
    @Field
    private String name;
    @Field
    private int age;
    
    /**
     * 可以给某个属性重命名,likes就是solr index的属性;在solrIndex中将显示like为likes
     */
    @Field("likes")
    private String[] like;
    @Field
    private String address;
    @Field
    private String sex;
    @Field
    private String remark;
    public int getId() {
        return id;
    }
    
    //setter 方法上面也可以
    @Field
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    //getter、setter
    
    @Override
    public String toString() {
        return this.id + "#" + this.name + "#" + this.age + "#" + this.like + "#" + this.address + "#" + this.sex + "#" + this.remark;
    }
}

测试类代码如下

package com.hoo.test;
 
import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.junit.Test;
import com.hoo.entity.User;
 
/**
 * <b>function:</b>SolrInputDocument implements Map, Iterable
 * @author hoojo
 * @createDate 2011-10-19 下午03:54:54
 * @file SolrInputDocumentTest.java
 * @package com.hoo.test
 * @project SolrExample
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
public class SolrInputDocumentTest {
 
    public final void fail(Object o) {
        System.out.println(o);
    }
    
    /**
     * <b>function:</b> 创建SolrInputDocument
     * @author hoojo
     * @createDate 2011-10-21 下午03:38:20
     */
    @Test
    public void createDoc() {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", System.currentTimeMillis());
        doc.addField("name", "SolrInputDocument");
        doc.addField("age", 22, 2.0f);
        
        doc.addField("like", new String[] { "music", "book", "sport" });
        
        doc.put("address", new SolrInputField("guangzhou"));
        
        doc.setField("sex", "man");
        doc.setField("remark", "china people", 2.0f);
        
        fail(doc);
    }
    
    /**
     * <b>function:</b> 利用DocumentObjectBinder对象将SolrInputDocument 和 User对象相互转换
     * @author hoojo
     * @createDate 2011-10-21 下午03:38:40
     */
    @Test
    public void docAndBean4Binder() {
        SolrDocument doc = new SolrDocument();
        doc.addField("id", 456);
        doc.addField("name", "SolrInputDocument");
        
        doc.addField("likes", new String[] { "music", "book", "sport" });
        
        doc.put("address", "guangzhou");
        
        doc.setField("sex", "man");
        doc.setField("remark", "china people");
        
        DocumentObjectBinder binder = new DocumentObjectBinder();
        
        User user = new User();
        user.setId(222);
        user.setName("JavaBean");
        user.setLike(new String[] { "music", "book", "sport" });
        user.setAddress("guangdong");
        
        fail(doc);
        // User ->> SolrInputDocument
        fail(binder.toSolrInputDocument(user));
        // SolrDocument ->> User
        fail(binder.getBean(User.class, doc));
        
        SolrDocumentList list = new SolrDocumentList();
        list.add(doc);
        list.add(doc);
        //SolrDocumentList ->> List
        fail(binder.getBeans(User.class, list));
    }
    
    /**
     * <b>function:</b> SolrInputDocument的相关方法
     * @author hoojo
     * @createDate 2011-10-21 下午03:44:30
     */
    @Test
    public void docMethod() {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", System.currentTimeMillis());
        doc.addField("name", "SolrInputDocument");
        doc.addField("age", 23, 1.0f);
        doc.addField("age", 22, 2.0f);
        doc.addField("age", 24, 0f);
        
        fail(doc.entrySet());
        fail(doc.get("age"));
        //排名有用,类似百度竞价排名
        doc.setDocumentBoost(2.0f);
        fail(doc.getDocumentBoost());
        fail(doc.getField("name"));
        fail(doc.getFieldNames());//keys
        fail(doc.getFieldValues("age"));
        fail(doc.getFieldValues("id"));
        fail(doc.values());
    }
}

利用SolrJ操作solr API完成index操作的更多相关文章

  1. Solrj调用Solr API

    在MyEclipse下的SSH项目,要调用Solr接口进行操作. 1.先运行solr 2.在已搭建好的SSH项目中用Solrj调用Solr的接口 3.导入如下solr的jar包到搭建好的SSH项目的W ...

  2. 使用solrJ操作solr常用方法 【注释非常详细,非常好】

    转: 使用solrJ操作solr常用方法 2017年08月07日 22:49:06 成都往右 阅读数:8990   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.cs ...

  3. ES6.3.2 index操作源码流程

    ES 6.3.2 index 操作源码流程 client 发送请求 TransportBulkAction#doExecute(Task,BulkRequest,listener) 解析请求,是否要自 ...

  4. Solr 09 - SolrJ操作Solr单机服务 (Solr的Java API)

    目录 1 SolrJ是什么 2 SolrJ对索引的CRUD操作 2.1 创建Maven工程(打包方式选择为jar) 2.2 配置pom.xml文件, 加入SolrJ的依赖 2.3 添加和修改索引 2. ...

  5. 使用solrj操作solr索引库,solr是lucene服务器

    客户端开发 Solrj 客户端开发 Solrj Solr是搭建好的lucene服务器 当然不可能完全满足一般的业务需求 可能 要针对各种的架构和业务调整 这里就需要用到Solrj了 Solrj是Sol ...

  6. Java操作Solr之SolrJ

    添加SolrJ的jar包 solrj是访问Solr服务的java客户端,提供索引和搜索的请求方法,SolrJ通常在嵌入在业务系统中,通过SolrJ的API接口操作Solr服务, <depende ...

  7. 使用solrj操作solr索引库

    (solrj)初次使用solr的开发人员总是很郁闷,不知道如何去操作solr索引库,以为只能用<五分钟solr4.5教程(搭建.运行)>中讲到的用xml文件的形式提交数据到索引库,其实没有 ...

  8. 利用 Java 操作 Jenkins API 实现对 Jenkins 的控制详解

    本文转载自利用 Java 操作 Jenkins API 实现对 Jenkins 的控制详解 导语 由于最近工作需要利用 Jenkins 远程 API 操作 Jenkins 来完成一些列操作,就抽空研究 ...

  9. SOLR使用手册之操作collection

    一.Collections API  参考:https://cwiki.apache.org/confluence/display/solr/Collections+API 因为API比较多,我就不一 ...

随机推荐

  1. Protel99 SE快捷键大全

    为了方便观看我们的protel99 se视频教程的朋友,我们在这里发布了protel99 se的所有的键盘的快捷分健大全,希望大家在学习我们的视频教程的时候,可以熟悉以下这些快捷键,因为平时我们用pr ...

  2. golang ODBC 访问access数据库(问题解决之心理路程)

    最近项目需要,需要操作access,以前是用VC++ OLE访问,网络用ACE库,感觉很庞大...决定用go试试 网上用的最多的就是这个https://github.com/weigj/go-odbc ...

  3. Oracle DBA常用的系统表

    1.2 DBA常用的表1.2.1  dba_开头    dba_users数据库用户信息    dba_segments  表段信息    dba_extents    数据区信息    dba_ob ...

  4. UVa 10131: Is Bigger Smarter?

    动态规划题.类似UVa103 Stacking Box,都是题目给一种判断嵌套的方法然后求最长序列.提前对数据排序可以节省一些时间开销. 我的解题代码如下: #include <iostream ...

  5. UVA 11754 - Code Feat(数论)

    UVA 11754 - Code Feat 题目链接 题意:给定一个c个x, y1,y2,y3..yk形式,前s小的答案满足s % x在集合y1, y2, y3 ... yk中 思路:LRJ大白例题, ...

  6. WINCE平台下C#应用程序中使用看门狗

    看门狗定时器(WDT,Watch Dog Timer)是单片机的一个组成部分,它实际上是一个计数器,一般给看门狗一个大数,程序开始运行后看门狗开始倒计数.如果程序运行正常,过一段时间CPU应发出指令让 ...

  7. 关于Stack Overflow上ASP.NET最大连接数限制提问的一个思考

    原文地址:Why request queuing is high even when request executing is below its limit? We are using below ...

  8. Orchard 添加搜索栏

    Orchard 提供索引和搜索的功能. 索引功能需要开启 Indexing 模块, 同时我们要开启Lucene 模块(做实际检索工作的东西). 然后还要开启Search模块(调用Lucene 查询然后 ...

  9. linux命令: patch

    一. 针对单文件的patch: 我们以mkprj.sh.1和mkprj.sh两个文件为例: [root@localhost tst]# lsmkprj.sh.1  mkprj.sh 看两个文件的差异: ...

  10. gets函数完美替代

    当我们在使用gets函数时候,因为不确定gets函数的buffer究竟有多大,所以这个函数只能用作是玩具函数.因此,当我们需要直接从输入得到一个东西的时候可以用fgets函数代替gets函数,这样不管 ...