首页 > 其他 > 详细

solr 嵌套entity 高亮查询

时间:2020-06-01 00:04:55      阅读:66      评论:0      收藏:0      [点我收藏+]

<document>

<entity name="course"
query="SELECT id,name,picture,description,type,price,hard,update_statue,introduce,original_cost,status from t_course">
<field column="id" name="id"/>
<field column="name" name="courseName"/>
<field column="picture" name="picture"/>
<field column="description" name="description"/>
<field column="type" name="type"/>
<field column="price" name="price"/>
<field column="hard" name="hard"/>
<field column="introduce" name="introduce"/>
<field column="update_statue" name="updateStatue"/>
<field column="original_cost" name="originalCost"/>
<field column="status" name="courseStatus"/>

<entity name="courseChapter"

query="SELECT id,name,video_id,status from t_course_chapter where course_id=‘${course.id}‘">

<field column="id" name="chatperId"/>
<field column="name" name="chapterName"/>
<field column="video_id" name="videoId"/>
<field column="status" name="chapterStatus"/>
</entity>

</entity>
</document>

这里是schema 的配置:

 


<field name="chapterName" type="text_ik" indexed="true" stored="true" multiValued="true" />
<field name="courseName" type="text_ik" indexed="true" stored="true" />
<field name="description" type="text_ik" indexed="true" stored="true" />
<field name="type" type="int" indexed="true" stored="true" />
<field name="price" type="double" indexed="true" stored="true" />
<field name="hard" type="int" indexed="true" stored="true" />
<field name="updateStatue" type="int" indexed="true" stored="true" />
<field name="originalCost" type="double" indexed="true" stored="true" />
<field name="picture" type="string" indexed="true" stored="true"/>
<field name="introduce" type="text_ik" indexed="true" stored="true"/>
<field name="courseStatus" type="int" indexed="true" stored="true"/>

<field name="videoId" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="chatperId" type="string" indexed="true" stored="true" required="true" multiValued="true" />

<field name="chapterStatus" type="int" indexed="true" stored="true" multiValued="true" />

<field name="keyWords" type="text_ik" indexed="true" stored="false" required="true" multiValued="true" />
<copyField source="courseName" dest="keyWords"/>
<copyField source="description" dest="keyWords"/>
<copyField source="chapterName" dest="keyWords"/>


<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />

开始做高亮查询时,发现一个问题,课时部分匹配的信息只有一个高亮显示,查了很多资料,有人说 field 的属性设置成multiValued=”true” 是不合适做高亮的。现在我通过实验发现,貌似确实是这样子(我不能确定是不是这个原因,没看过solr源码),但是我做实验发现个问题,看截图:


搜索关键字 “制作”,发现chapterName 里有个记录里没有包含制作的也查出来了,从实验现象来说他把这些记录看成是一条记录了,也就是只要有一个匹配他就算,所以这一步有问题,那么高亮显示也就不会正确显示了。

重新调整思路: 不做实体嵌套设置,将实体分开来设置,先查询课程,然后再查询可是数据,但是这样一来,一次查询就变成 1+N次了。
————————————————
版权声明:本文为CSDN博主「feijiing」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/feijiing/article/details/71669194

solr 嵌套entity 高亮查询

原文:https://www.cnblogs.com/wangwenlong8/p/13021992.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!