zoukankan      html  css  js  c++  java
  • 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();
        }
    }
  • 相关阅读:
    基于Docker的Mysql主从复制搭建
    Docker操作命令——查看、停止、删除容器
    Git命令
    未定义数组下标: 0
    zookeeper-3.4.14单机多端口集群搭建
    使用MAT分析dump文件定位程序问题
    intellij idea2019.1中文破解版安装
    vscode打造golang开发环境
    python项目开发环境模块安装记录
    shell用法
  • 原文地址:https://www.cnblogs.com/xlhlx/p/10743665.html
Copyright © 2011-2022 走看看