在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>
iCMS 回答:在solr中保留多值中的关联或位置

重要的是要注意,只要存储了字段就保留顺序(并且不仅启用了docValues)-第一个日期将是发送到该字段的第一个日期,然后可以将其映射到第一个日期在第二个字段中。

但是,您要查找的是一个相关查询,其中每个字段都相对于另一个查询。在那种情况下,可以通过显式定义每个值或使用动态字段名将每个值本身索引为字段。

fecha_referencia_publicacion: "2020-05-24",fecha_referencia_creacion: "2018-01-18",...

这样,您可以像往常一样在字段上执行任何范围查询和构面。

或者,如果您只需要精确匹配,则可以将一个连接的值编入索引,其中类型和日期都被编入同一字段:

fecha_referencia: "Publicacion_2020-05-24"
本文链接:https://www.f2er.com/1723512.html

大家都在问