简体   繁体   English

Solr数据导入处理程序查询

[英]Solr dataimport handler query

I have following a dataimport handler: 我有以下数据导入处理程序:

<entity name="Categories" query="Select * From Categories">

  <field column="Name" name="categoryNgram"/>


    <entity name="CategorySynonyms" query="Select Synonym From CategorySynonyms Where CID='${Categories.Id}'">  

     <field column="Synonym" name="synonym"/>   

    </entity>

</entity>

The database tables have following values: 数据库表具有以下值:

Categories 分类目录

Id Name 编号名称

1 Category1 1个类别1

CategorySynonyms 类别同义词

CID 客户编号

1 CategorySynonym1 1 CategorySynonym2 1 CategorySynonym1 1 CategorySynonym2

In the result is says Total Rows Fetched: 3 结果是说提取的总行数:3

But when i select all from index : i only receive one row in the result: 但是,当我从index中选择全部时结果中只收到一行:

Category1 SynonymCategory1 Category1同义词Category1

Is there something wrong with the syntax that makes it create only one document when is should create two? 使它仅创建一个文档而应该创建两个文档的语法有什么问题吗?

It's expected as the total number of rows fetched from database is 3 (1 from table Categories and 2 from CategorySynonyms ). 可以预期,因为从数据库中获取的总行数为3(从表Categories中获取1行,从CategorySynonyms中获取 2行)。

The total number of document in solr is 1, as expected too: solr中的文档总数也为1,这与预期的一样:

Name:Category1,
Synonym: CategorySynonym1,CategorySynonym2

Perhaps you can try 也许你可以尝试

<entity name="Categories" query="Select CID,Name,Synonym From Categories join CategorySynonyms on Id=CID">
  <field column="Name" name="categoryNgram"/>
  <field column="Synonym" name="synonym"/>   
</entity>

Note: you may have to verify the SQL query to make sure it returns an Id field, and two rows as you would expected. 注意:您可能必须验证SQL查询,以确保它返回一个Id字段,并按预期返回两行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM