Solr 创建索引

1. 索引目录结构

solr-4.9.0/example/solr/collection1(example/example-schemaless/solr/collection1)是SolrCore的实例目录示例,当建立一个新的SolrCore时,不必拷贝这个目录的所有文件,但推荐这样做。

 基本目录结构

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

Solr主目录通常包含下面的子目录…

   conf/

       这个目录是必需的并且必须包含solrconfig.xml和schema.xml. 任何其他可选的配置文件也应该放在这里。

   data/

       这个目录是存放索引的默认位置,并且被replication脚本用来处理snapshots. 你可以在conf/solrconfig.xml中覆盖这个目录。如果目录不存在,Solr会自动创建。

   lib/

        这个目录是可选的。如果存在,Solr将载目录中的Jars,并且用来解决你在solrconfig.xml或schema.xml中配置的任何插件(如,Analyzers, RequestHandlers, 等…)。替代的,你可以在conf/solrconfig.xml中使用<lib>语法来指定你的插件。


2. 新建索引集合

新建名为new_core的索引集合: 
1) 在solr服务目录下创建new_core目录,拷贝collection1/conf目录至new_core下。(以后可编辑conf/schema.xml为集合的文档配置模式)
2) 在Solr Admin管理界面的Core Admin中,通过Add Core可以创建一个索引集合。CoreAdmin -> Add Core

---- Add Core报错1:

ErrorCREATEing SolrCore 'resume': Unable to create core: resume Caused by: _version_field must exist in schema, using indexed="true" ordocValues="true", stored="true" andmultiValued="false" (_version_ does not exist)

在schema.xml中需要添加field,<field name="_version_"type="long"    indexed="true" stored="true"/>

---- Add Core报错2:

Error CREATEing SolrCore 'position': Unable tocreate core: position Caused by: Invalid Number: MA147LL/A

---------

Note that if youhave enabled the QueryElevationComponent insolrconfig.xml it requires the schema to have auniqueKey of typeStrField. It cannot be, forexample, an int field.

Otherwise, you willget exception like:

java.lang.NumberFormatException:For input string: "MA147LL/A"

-----

在solrconfig.xml中启用QueryElevationComponent (结果置顶功能)需要有一个StrField类型的唯一键,启用这个功能需要配置elevate.xml,查看elevate.xml

 

<elevate>

 <query text="foo bar">

  <doc id="1" />

  <doc id="2" />

  <doc id="3" />

 </query>

 

 <query text="ipod">

   <doc id="MA147LL/A"/>  <!-- put the actual ipod at thetop -->

   <doc id="IW-02"exclude="true" /> <!-- exclude this cable -->

 </query>

 

这是从core0拷贝过来的默认配置,id为String,而在自己的集合配置中ID字段是整型的。

不需要使用这个功能,将下面的配置注释掉,重新添加集合即可。

 

------ conf/solrconfig.xml-----

  <!-- Query Elevation Component

      http://wiki.apache.org/solr/QueryElevationComponent

       a search component that enables you toconfigure the top

       results for a given query regardless ofthe normal lucene

       scoring.

-->

<!--

  <searchComponent name="elevator"class="solr.QueryElevationComponent" >

-->

<!-- pick a fieldType to analyze queries -->

<!--

    <strname="queryFieldType">string</str>

    <strname="config-file">elevate.xml</str>

  </searchComponent>

-->




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值