• solr


    1:solr是什么?

    说白了底层就是lucene

    --------------------------------------------------

    2:入门级小案列

    public class IndexWriterTest {

        /**
         * 添加索引库的操作
         */
        @Test
        public void indexWriterTest01() throws IOException, SolrServerException {
            //1. 创建一个solr的连接对象 solrServer
            /**
             * 注意:浏览器的url:http://localhost:8080/solr/#/collection1
             * java代码里面去掉井号
             */
            String baseURL = "http://localhost:8080/solr/collection1";
            HttpSolrServer httpSolrServer = new HttpSolrServer(baseURL);

            //2. 创建document对象
            SolrInputDocument doc = new SolrInputDocument();
            /**
             * field字段的名称必须在schema.xml文件中配置过,才能使用
             */
            doc.addField("id","5");
            doc.addField("title","王祖蓝陪产部分画面曝光,为李亚男整理头发画面超有爱");
            doc.addField("content","王祖蓝录制完节目马上赶回香港去陪产 路上回忆和老婆的点点滴滴");
            doc.addField("editor","吃瓜群众");
            //3. 添加索引
            httpSolrServer.add(doc);
            //4. 提交
            httpSolrServer.commit();
            //5. 关闭资源
            httpSolrServer.shutdown();
        }
    }
  • 相关阅读:
    Reflector8使用技术
    Rose UML 活动图的画法
    .NET 4.0里异常处理的新机制-处理P/Invoker调用异常处理
    数据结构-树的相关算法
    Project 2013 使用大全
    .NET C#开发Activex系列之一:Activex发展背景
    C# Activex开发、打包、签名、发布
    Project 2013 理论基础
    UML类图与类的关系
    RUP(Rational Unified Process)统一软件开发过程
  • 原文地址:https://www.cnblogs.com/xlhlx/p/10743665.html
Copyright © 2020-2023  润新知