2011-04-12 57 views
3

我是solr的新手。我有几个关于Solr的索引和搜索的问题:如何使用单个solr实例(两个不同的搜索字段没有连接)对两个不同的表进行索引和搜索(两个不同的搜索字段没有连接)

  1. 我可以配置指数两个表(没有任何关系1.书籍和2电脑又都是在同一个数据源)如果我想有两个搜索框。是否有可能做一个像在一个data-config.xml中定义两个实体

如果是,请让我知道的步骤。

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

  1. 如何将solr配置为索引一个solr实例上的PDF文件和Mysql。

请帮帮我,让我们知道是否有任何参考文件。

回答

0

您可以轻松地使用Solr做到这一点,只需要一个良好的阅读在DataImportHandler: http://wiki.apache.org/solr/DataImportHandler 和这个例子: http://wiki.apache.org/solr/MultipleIndexes

然后做一些googleing各地的关于实体的具体例子。基本上,你的数据-config.xml中想是这样的(未测试):

<entity name="books" transformer="TemplateTransformer" dataSource="myindex" 
     query="SELECT * FROM t_books";> 
<field column="category" template="books" name="category"/></entity> 
<entity name="computers" 
      dataSource="myindex" 
     query="SELECT * FROM t_computers"> 
    <field column="category" template="computers" name="category"/></entity> 

使用模板的两个实体分开,并定义类别字段为您schema.xml中的字符串。此外,请确保你注意你是如何设置的唯一ID参数,对于这个特定主题的一些信息是在这里: http://lucene.472066.n3.nabble.com/Indexing-multiple-entities-td504464.html 并检查在这里: http://search.lucidimagination.com/search/document/f84c3abf7e859be1/dataimporthanlder_multiple_entities_will_step_into_each_other

通过这种方法,你必须在这两组数据同样的指数,如果你希望他们为两个独立的搜索框工作,你可以简单地运行您的搜索,如:

更改为MyQuery和类别:(书籍)< ---这只会让你从书本结果或者这另一个只会让你的计算机结果---> myquery和类别:(电脑)。 希望它有帮助。 并为您的PDF的问题,我认为你必须使用Apache的提卡模块,我不会在这里多的帮助,我没有用它自己,但这里的链接: http://wiki.apache.org/solr/TikaEntityProcessor

+0

当我试图指数两个Entity这种风格,它甚至没有编入索引的实体。 – 2014-03-20 10:33:06

+0

请参考以下链接:http://stackoverflow.com/questions/22534121/how-to-index-and-search-two-different-tables-which-are-in-same-datasource-using – 2014-03-20 13:20:30

5

2个不同的表没有关系

数据-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> 

架构。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/

没有上述领域应要求或建立索引时

可能会产生问题

你可以在浏览器查询像http://localhost:8080/solr/select/?q=*:*&fq=doc_type:PRODUCT

+0

救星,谢谢。 – bluehallu 2013-08-22 09:41:15

相关问题