- zy19982004
- 等级: 初级会员
- 性别:
- 文章: 15
- 积分: 30
- 来自: 深圳
|
发表时间:2010-11-08
最后修改:2010-11-08
关于solr配置文件小编理解的,大部分都是可以在网上查到的。所以小编主要列举下一些网上大家谈的很少的知识。
1.solrconfig.xml
- 配置文件(略)
- 这个文件,我没做很深入的研究。只有一点说明,solr1.3和solr1.4是有区别的
- solr1.3里面,需要指定solr index date的位置
<!-- Used to specify an alternate directory to hold all index data
other than the default ./data under the Solr home.
If replication is in use, this should match the replication configuration. -->
<dataDir>${solr.data.dir:./solr/db/data}</dataDir>
- solr1.4里面,自动把生成index目录:data(和conf同级)-index (索引文件)
<!-- The directory where your SpellChecker Index should live. -->
<!-- May be absolute, or relative to the Solr "dataDir" directory. -->
<!-- If this option is not specified, a RAM directory will be used -->
<str name="spellcheckerIndexDir">spell</str>
2.db-data-config.xml
- 配置文件(人所在的公司为例)
<!--dataConfig is designed for member search, by using the table member,organization-->
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://../test" user=".."
password=".." />
<document name="private-beta">
<!-- field for news search, from member table-->
<entity name="member" pk="memid"
query="select distinct * from member"
deltaQuery="select memid from member
where mem_date_updated > '${dataimporter.last_index_time}'">
<field column="memid" name="memid" />
<field column="name" name="name" />
<field column="mem_first_name" name="mem_first_name" />
<field column="mem_last_name" name="mem_last_name" />
<field column="mem_org_title" name="mem_org_title" />
<field column="mem_org_dept" name="mem_org_dept" />
<field column="mem_job_func" name="mem_job_func" />
<field column="mem_job_level" name="mem_job_level" />
<field column="mem_add_city" name="mem_add_city" />
<field column="mem_add_state_code" name="mem_add_state_code" />
<field column="mem_add_country_code" name="mem_add_country_code" />
<field column="mem_date_created" name="mem_date_created" />
<field column="mem_email" name="mem_email" />
<field column="mem_orgid" name="mem_orgid" />
<field column="mem_add_address" name="mem_add_address" />
<!-- field for member search, from organization table-->
<entity name="organization" pk="orgid"
query="select * from organization where orgid='${member.mem_orgid}'" >
<field column="orgid" name="orgid" />
<field column="org_name" name="org_name" />
<field column="org_website" name="org_website" />
<field column="org_website_protocol" name="org_website_protocol" />
<field column="org_subcat_id" name="org_subcat_id" />
<field column="org_subcat_id2" name="org_subcat_id2" />
<field column="org_subcat_id3" name="org_subcat_id3" />
<field column="org_subcat_id4" name="org_subcat_id4" />
<field column="org_subcat_id5" name="org_subcat_id5" />
</entity>
</entity>
</document>
</dataConfig>
3.schema.xml
- 配置文件
<!-- This is an example oTokenFilterFactoriesf using the KeywordTokenizer along
With various to produce a sortable field
that does not include some properties of the source text
-->
<fieldType name="alphaOnlySort" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<!-- KeywordTokenizer does no actual tokenizing, so the entire
input string is preserved as a single token
-->
<tokenizer class="solr.KeywordTokenizerFactory"/>
<!-- The LowerCase TokenFilter does what you expect, which can be
when you want your sorting to be case insensitive
-->
<filter class="solr.LowerCaseFilterFactory" />
<!-- The TrimFilter removes any leading or trailing whitespace -->
<filter class="solr.TrimFilterFactory" />
<!-- The PatternReplaceFilter gives you the flexibility to use
Java Regular expression to replace any sequence of characters
matching a pattern with an arbitrary replacement string,
which may include back refrences to portions of the orriginal
string matched by the pattern.
See the Java Regular Expression documentation for more
infomation on pattern and replacement string syntax.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
-->
<filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z])" replacement="" replace="all"
/>
</analyzer>
</fieldType>
<fields>
<!-- field for member search,all field is in one-to-one correspondence with the field in db-data-config.xml -->
<!-- field from member table-->
<field name="memid" type="long" indexed="true" stored="true"
multiValued="false" required="true"/>
...
<field name="mem_orgid" type="long" indexed="true" stored="true"
multiValued="false"/>
<!-- field from organization table-->
<field name="orgid" type="long" indexed="true" stored="true"
multiValued="false"/>
<field name="org_name" type="alphaOnlySort" indexed="true" stored="true"
multiValued="false" />
...
- alphaOnlySort:对于org_name这样的field,一般我们会将其定义为text类型,如果同时我们需要按org_name排序,那怎么办?显然,text是不能用了。刚好,alphaOnlySort,可以为我们解决这个问题,你应该可以理解上面那段配置。
- 特别要说明的是<filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z])" replacement="" replace="all"
/>,排除了所有非字母的文本。举个例子,按上面的配置,你查找“123”这样的公司名,它会匹配到任何公司名为数字的公司。所以我把这段给注释掉了。
- 如果选择了alphaOnlySort,输入ibm,将无法匹配到ibm.com,因为alphaOnlySort类型的ibm.com并不会被分割(<filter class="solr.WordDelimiterFilterFactory...")。
4.stopwords.txt
- 配置文件(略)
- stopwords,只针对定义了texttype的field。
- 里面定义的一些停用词我们需要注意了,比喻“OR”,你能把它停掉吗。不一定,美国就有Oregon洲缩写为OR,如果你把org_state_code的fieldtype设置为text的话,你搜索OR,传到solr server的url:http://localhost:8888/solr/../select?q=*:*?&fq=org_state_code:OR就会变成http://localhost:8888/solr/../select?q=*:*?&fq=org_state_code:,报错!
- 所以,要么你将org_state_code定义为其他fieldtype,要么你在stopwords里面除掉这些特殊的words。
文章写的比较肤浅,见笑了。如有不妥之处,欢迎大家纠正。
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|