Question

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

CategorySynonyms

CID

1 CategorySynonym1 1 CategorySynonym2

In the result is says Total Rows Fetched: 3

But when i select all from index : i only receive one row in the result:

Category1 SynonymCategory1

Is there something wrong with the syntax that makes it create only one document when is should create two?

Was it helpful?

Solution

It's expected as the total number of rows fetched from database is 3 (1 from table Categories and 2 from CategorySynonyms).

The total number of document in solr is 1, as expected too:

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top