zoukankan      html  css  js  c++  java
  • SpringDataSolr相关配置

    Solr相关配置

    一.配置IK分词器

    1.IKAnalyzer2012FF_u1.jar 添加到 solr 工程的 lib 目录下

    2、创建WEB-INF/classes文件夹  把扩展词典、停用词词典、配置文件放到 solr 工程的 WEB-INF/classes 目录下。

    3、修改 Solrhome 的 schema.xml 文件,配置一个 FieldType,使用 IKAnalyzer,最后面加上

    <fieldType name="text_ik" class="solr.TextField">
    
         <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
    
    </fieldType>

    二.配置域

    Solrhome 的 schema.xml 文件,最后面加上

         <!--配置域-->
        <field name="item_goodsid" type="long" indexed="true" stored="true"/>
        <field name="item_title" type="text_ik" indexed="true" stored="true"/>
        <field name="item_price" type="double" indexed="true" stored="true"/>
        <field name="item_image" type="string" indexed="false" stored="true" />
        <field name="item_category" type="string" indexed="true" stored="true" />
        <field name="item_seller" type="text_ik" indexed="true" stored="true" />
        <field name="item_brand" type="string" indexed="true" stored="true" />
        
        <!--配置复制域,业务用于组合查询时查询-->
        <field name="item_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/>
        <copyField source="item_title" dest="item_keywords"/>
        <copyField source="item_category" dest="item_keywords"/>
        <copyField source="item_seller" dest="item_keywords"/>
        <copyField source="item_brand" dest="item_keywords"/>
        
        <!--配置动态域-->
        <dynamicField name="item_spec_*" type="string" indexed="true" stored="true" />    

    SpringDataSolr配置

    applicationContext-solr.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:solr="http://www.springframework.org/schema/data/solr"
        xsi:schemaLocation="http://www.springframework.org/schema/data/solr 
              http://www.springframework.org/schema/data/solr/spring-solr-1.0.xsd
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd">
        <!-- solr服务器地址 -->
        <solr:solr-server id="solrServer" url="http://192.168.25.129:8081/solr-4.10.3" />
        <!-- solr模板,使用solr模板可对索引库进行CRUD的操作 -->
        <bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
            <constructor-arg ref="solrServer" />
        </bean>
    </beans>

  • 相关阅读:
    VB Treeview控件 介绍与使用
    基于V4L2的视频驱动开发
    Jlinkv8 灯不亮重新烧写固件的办法
    使用JLink间接烧写S3C2410、S3C2440开发板Nor、Nand Flash的方法
    linux 开机自动执行脚本或者一些指定的程序
    FrameBuffer编程二(简单程序下)
    c语言内存分配函数
    FrameBuffer编程二(简单的程序上)
    FrameBuffer编程一(数据结构)
    mmap函数介绍
  • 原文地址:https://www.cnblogs.com/binghuaZhang/p/14196972.html
Copyright © 2011-2022 走看看