如何使用单个 solr 实例索引和搜索同一数据源中的两个不同表(两个不同的搜索字段没有连接) [英] How to index and search two different tables which are in same datasource using single solr instance(two different search fields no joins)

查看:21
本文介绍了如何使用单个 solr 实例索引和搜索同一数据源中的两个不同表(两个不同的搜索字段没有连接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 solr 的新手.我有几个关于 solr 索引和搜索的问题:

I am new to solr. I have couple of questions on solr Indexing and searching:

  1. 如果我想要两个搜索框,我可以配置为索引两个表吗(没有关系 1. 书籍和 2. 计算机并且两者都在同一个数据源中).是否可以在一个 data-config.xml 中定义两个实体

如果是,请告诉我步骤.

If yes please let me know the steps.

我想我们可以使用两个不同的 data-config.xml 文件.但是需要知道如何在schema.xml中进行配置和相应的修改.

I guess we can do using two different data-config.xml files. But need to know how to configure in schema.xml and corresponding changes.

  1. 如何配置 solr 以在一个 solr 实例上同时索引 PDF 文件和 Mysql.

请帮助我,如果有任何参考文件,请告知.

Please help me out and let know if there are any reference documents.

推荐答案

2个不同的表没有关系

data-config.xml:

    <document>
        <entity name="topic" transformer="TemplateTransformer" pk="topic_id" query="select topic_id,topic_title,creation_date,updation_date,vote_count,.....">
            <field column=" doc_id " template="TOPIC_${topic.topic_id} " />
            <field column="doc_type " template="TOPIC " />

        </entity>

        <entity name="product " transformer="TemplateTransformer " pk="product_id " query="SELECT product_id,..... ">
            <field column="doc_id " template="PRODUCT_${product.product_id} " />
            <field column="doc_type " template="PRODUCT " />
            <field column="product_supplier_id " name="product_supplier_id " />
            <field column="supplier_product_code " name="supplier_product_code " />
            <field column="product_display_name " name="product_display_name " />
        </entity>
    </document>

schema.xml:

    <schema>
        . . .
        <fields>

            <field name="doc_id" type="string" />
            <field name="doc_type" type="string" />

            <field name="catchall" type="string" stored="false" omitNorms="true" multiValued="true" />


            <field name="topic_title" type="text_general" />. . . .
        </fields>

        <uniqueKey>doc_id</uniqueKey>
        <copyField source="*" dest="catchall" />

        <!-- field for the QueryParser to use when an explicit fieldname is absent -->
        <defaultSearchField>catchall</defaultSearchField>
    </schema>

更多信息 -http://www.lucidimagination.com/blog/2011/02/12/solr-powered-isfdb-part-4/

以上字段不应该是必需的,否则可能会在索引时产生问题

no above field should be required or may create problem while indexing

您可以在浏览器上查询,如http://localhost:8080/solr/select/?q=*:*&fq=doc_type:PRODUCT

you can query on browser like http://localhost:8080/solr/select/?q=*:*&fq=doc_type:PRODUCT

这篇关于如何使用单个 solr 实例索引和搜索同一数据源中的两个不同表(两个不同的搜索字段没有连接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆