solr实体嵌套、字段加权查询
来源:互联网 发布:android开发计算器源码 编辑:程序博客网 时间:2024/05/20 20:44
创建索引时可能遇到实体嵌套的情况,比如学生信息中包含多个活动。
注意子field中需要配置multiValued="true"
这样配置完成后创建的索引显示结果如下:
配置查询时加权:
在solr的data-config.xml中配置:
<entity name="studentProfile" pk="ID" query="select CONCAT('studentProfile',studentProfileId) as solr_id,studentProfileId,name,location,description from studentProfile" deltaQuery="select sp.studentProfileId as ID from studentProfile sp,users u where u.registerTime > '${dataimporter.last_index_time}' and sp.email=u.email " deltaImportQuery="select CONCAT('studentProfile',studentProfileId) as solr_id,studentProfileId,name,location,description from studentProfile where studentProfileId='${dataimporter.delta.ID}'" > <field name="id" column="solr_id"/> <field name="studentprofile_id" column="studentProfileId"/> <field name="studentprofile_name" column="name"/> <field name="studentprofile_location" column="location"/> <field name="studentprofile_description" column="description"/> <field name="studentprofile_publicUri" column="publicUri"/> <entity name="activity" query="select activityId,title,description from activity where studentProfileId = '${studentProfile.studentProfileId}' " > <field name="activity_id" column="activityId"/> <field name="activity_title" column="title"/> <field name="activity_description" column="description"/> </entity></entity>
注意${studentProfile.studentProfileId}的写法。
在schema.xml中配置:
<field name="studentprofile_id" type="string" indexed="true" stored="true" /> <field name="studentprofile_name" type="text_mmseg4j" indexed="true" stored="true" /> <field name="studentprofile_location" type="text_mmseg4j" indexed="true" stored="true" /> <field name="studentprofile_description" type="text_mmseg4j" indexed="true" stored="true" /> <field name="studentprofile_publicUri" type="text_mmseg4j" indexed="true" stored="true" /> <field name="activity_id" type="string" indexed="true" stored="true" multiValued="true"/> <field name="activity_title" type="text_mmseg4j" indexed="true" stored="true" multiValued="true"/> <field name="activity_description" type="text_mmseg4j" indexed="true" stored="true" multiValued="true"/>
注意子field中需要配置multiValued="true"
这样配置完成后创建的索引显示结果如下:
"docs": [ { "id": "studentProfile6315bbe5-399f-49b3-9382-b5fb0c2e8e2c", "studentprofile_location": "beijing", "studentprofile_name": "lcq", "studentprofile_id": "6315bbe5-399f-49b3-9382-b5fb0c2e8e2c", "activity_id": [ "1", "2" ], "activity_title": [ "dfsfs", "fsfs" ], "activity_description": [ "lcq", "haha" ], "_version_": 1527223001237422000 } ]
配置查询时加权:
在solrconfig.xml中添加
<requestHandler name="search" class="solr.SearchHandler" default="true"> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="defType">dismax</str> <str name="qf"> studentprofile_name^1 studentprofile_description^0.8 </str> <str name="q.alt">*:*</str> <str name="rows">10</str> <str name="fl">*,score</str> </lst> </requestHandler>使用solrj查询时:
query.set("qt","search");即可。
0 0
- solr实体嵌套、字段加权查询
- solr 标准查询解析器的加权
- Solr对分词字段进行完全匹配加权的操作
- Solr查询空值字段
- JPA查询实体部分字段
- solr查询字段不等于,solr过滤条件查询
- solr 嵌套entity 高亮查询
- solr搜索引擎 copyField字段 检索查询
- crm查询实体的字段属性
- crmsql语句查询实体窗体实体字段关系信息
- crm服务查询实体和实体的字段信息
- es 字段加权重
- solr入门之Solr函数查询初使用之查询字段是否包含指定内容
- lucene-查询表达式加权
- solr 创建日期索引字段和日期查询
- solr查询空值、null、不存在的字段的方法
- Solr中文字段的查询与字段分词后如何聚合查询的问题
- play Framework如何通过实体.find查询Date类型字段
- 详解Android中AsyncTask的使用
- 日期和时间?&字符串?
- 剑指offer相关题目,输入两个字符串,从第一个字符串中删除在第二个字符串中出现的所有字符
- HDFS一些参数的设置说明
- 题目标题: 高斯日记
- solr实体嵌套、字段加权查询
- linux 网络连接
- 使用ASIHTTPRequest和ASIDownloadCache实现本地缓存
- alter修改数据库表
- 网站架构
- [2016/02/27] PAT(Basic Level) Problem 1001-1050 JAVA略解
- window.open网页自适应不同分辨率方法
- UIKit继承图
- 带分隔符的字符串转换为数组绝对实用