solr - 在 solr 中保留多值的关联或位置
问题描述
我的 solr 数据源中有多值字段。样本是
<doc>
<str name="id">23606</str>
<arr name="fecha_referencia">
<str>2020-05-24</str>
<str>2018-01-18</str>
<str>1997-07-22</str>
</arr>
<arr name="tipo_de_fecha">
<str>Publicacion</str>
<str>Creación</str>
<str>Edicion</str>
</arr>
</doc>
但关键是,当我进行搜索时,我希望日期 2020-05-24属于“发布”日期类型,因为 solr 不处理位置,而是在 reference_date 和 date_type 的数组之间查找至少一个匹配项.
问题是:如何在 solr 中保留多值的排序/映射?
这是我的 data-config.xml 结构:
<dataConfig>
<dataSource type="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://10.152.11.47:5433/metadatos" user="us_me" password="ntm" URIEncoding="UTF-8" />
<document >
<entity name="tr_ident" query="SELECT id_ident, titulo,proposito,descripcion,palabra_cve
FROM ntm_p.tr_ident">
<field column="id_ident" name="id_ident" />
<field column="titulo" name="titulo" />
<field column="proposito" name="proposito" />
<entity name="ti_fecha_evento"
query="select tipo_fecha,fecha_referencia from ntm_p.ti_fecha_evento where id_fecha_evento='${tr_ident.id_ident}'">
<field column="fecha_referencia" name="fecha_referencia" />
<entity name="tc_tipo_fecha" query="select des_tipo_fecha,id_tipo_fecha from ntm_p.tc_tipo_fecha where id_tipo_fecha='${ti_fecha_evento.tipo_fecha}'">
<field column="id_tipo_fecha" name="id_tipo_fecha" />
</entity>
</entity>
</entity>
</document>
</dataConfig>
解决方案
重要的是要注意,只要存储字段(而不仅仅是启用 docValues),就会保留排序 - 第一个日期将是发送到该字段的第一个日期,然后可以映射到第二场。
但是,您要查找的是从属查询,其中每个字段都相对于另一个字段进行查询。在这种情况下,将每个值作为一个字段单独索引 - 通过显式定义它们或使用动态字段名称。
fecha_referencia_publicacion: "2020-05-24",
fecha_referencia_creacion: "2018-01-18",
...
这样您就可以像往常一样在该字段上执行任何范围查询和分面。
或者,如果您只需要精确命中,您可以索引一个连接值,其中类型和日期都被索引到同一字段中:
fecha_referencia: "Publicacion_2020-05-24"
推荐阅读
- asp.net-core-mvc - 从 ASP.NET MVC 项目调用 .NET CORE 5 Web API 微服务时无法检索 BadRequest 错误
- go - 如何在不同的构建版本中获取相同的文件路径
- c - 给定 GStreamer 管道中的总线程数是多少?
- typescript - 使用“可扩展媒体记录器”打字稿保存文件记录
- javascript - 车把 - 多个对象
- vue.js - 获取菜单和子菜单js的数组vue中的值数组
- android - cannot load image from Glide
- ruby-on-rails - Why are tests failing in Ruby on Rails?
- asp.net - 如何在 ASP.NET 中使用复选框检查更改而不刷新页面
- .net - 在 .NET Framework 上开发的应用程序是否可以在 .NET Core 上运行