solr <defaultSearchField>

本文介绍了如何在Solr中配置默认搜索字段,通过修改schema.xml文件中的&lt;defaultSearchField&gt;元素来指定默认搜索域。此外还讨论了这种方式对于获取高亮信息的影响。
在schema.xml中。

<defaultSearchField>text</defaultSearchField>

如果在localhost/solr/admin中直接搜索文字, 而不是title:xx,
就会搜索这个text域的索引内容。

所以如果我们想直接搜索某个域的索引, 只要修改这里就行了。


================
[b]不可以设置多个[/b]
比如
<defaultSearchField>msg_title</defaultSearchField>
<defaultSearchField>msg_content</defaultSearchField>
会导致默认的搜索域为msg_title, 颠倒顺序后就会变成msg_content.


之前的做法是
 <defaultSearchField>msg_all</defaultSearchField>
<copyField source="msg_title" dest="msg_all"/>
<copyField source="msg_content" dest="msg_all"/>


但是这样会影响到获取高亮。
比如

List<String> h_title = resp.getHighlighting().get(id)
.get("msg_title");

上面的代码会返回控制。
因为resp里面只有msg_all, 这样就会混淆高亮的显示。
我的solr 链接配置文件 为xml,内容如下。我有很多个.netcore,我想注入solr 链接来实现在Controller 中调用solr。xml内容:<?xml version="1.0" encoding="UTF-8"?> <castle> <facilities> <facility id='solr' type='Castle.Facilities.SolrNetIntegration.SolrNetFacility, Castle.Facilities.SolrNetIntegration'> <solrURL>http://127.0.0.1:8983/solr/</solrURL> <cores> <core id='MedTCMDisease'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMDisease</url> </core> <core id='MedTCM'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCM</url> </core> <core id='MedTCMZhongChengYao'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMZhongChengYao</url> </core> <core id='MedTCMFangJi'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMFangJi</url> </core> <core id='MedTCMZhenJiu'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMZhenJiu</url> </core> <core id='MedTCM_L'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCM_L</url> </core> <core id='MedTCMBianzhengLunzhi'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMBianzhengLunzhi</url> </core> <core id='MedTCMMulu'> <documentType>System.Collections.Generic.Dictionary`2[System.String,System.Object]</documentType> <url>http://127.0.0.1:8983/solr/MedTCMMulu</url> </core> </cores> </facility> </facilities> </castle>
最新发布
07-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值