solr4.x设置默认查询字段

1、如果需要同时在title和content中进行查询,可以添加如下字段:
<field name="title_content" type="textComplex" indexed="true" stored="false" multiValued="true"/>
<copyField source="my_title" dest="title_content"/>
<copyField source="my_content" dest="title_content"/>
其中:title_content为新定义的查询字段,如果需要同时在title和content中进行查询,那么就使用这个查询字段

2、设置默认查询字段,这样的话就不需要在Query中进行查询时使用my_title:hello这样的格式

将solrconfig.xml中得 <str name="df">text</str>
修改为: <str name="df">title_content</str>

这样,如果需要查询内容在标题字段或内容字段出现的结果的时候,只需要在查询条件中填写hello就可以了

扫扫关注“茶爸爸”微信公众号
坚持最初的执着,从不曾有半点懈怠,为优秀而努力,为证明自己而活。
回复:"茶爸爸"       看看有什么!!

原文地址:https://www.cnblogs.com/duyinqiang/p/5696682.html