You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sanjay92 <sa...@hotmail.com> on 2014/04/03 20:08:56 UTC

How do I add another unrelated query results to solr index

Hi,
How do I add two different queries into one single index.
e..g.
I have added following
      <entity name="salgrade" rootEntity="true"  query="select
grade,losal,hisal from salgrade" >
                <field column="GRADE" name="grade" />
                <field column="LOSAL" name="losal" />
                <field column="HISAL" name="hisal" />
      </entity>

But when I query, I dont see any data from salgrade table.
I have also tried another document tag but that also did not work as
expected.
Is it possible ?

<dataConfig>
  <dataSource type="JdbcDataSource"
              driver="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@mydb:1521:SID"
              user="****"
              password="****"  />
  <document>
      <entity name="salgrade" rootEntity="true"  query="select
grade,losal,hisal from salgrade" >
                <field column="GRADE" name="grade" />
                <field column="LOSAL" name="losal" />
                <field column="HISAL" name="hisal" />
      </entity>
    <entity name="mydept"  rootEntity="true" query="select deptno,dname,loc
from dept">
            <field column="DEPTNO" name="deptno" />
            <field column="DNAME" name="dname" />
            <field column="LOC" name="loc" />
            <entity name="myemp" query="select ename,job from emp where
deptno=${mydept.DEPTNO} " >
               <field column="ENAME" name="ename" />
               <field column="JOB" name="job" />
            </entity>
    </entity>
    
  </document>
  
</dataConfig>




--
View this message in context: http://lucene.472066.n3.nabble.com/How-do-I-add-another-unrelated-query-results-to-solr-index-tp4128932.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: How do I add another unrelated query results to solr index

Posted by sanjay92 <sa...@hotmail.com>.
I think it was not just rootEntity="true".

We need to add transformer="TemplateTransformer"  and make sure that each
entity has some kind of Unique column across all entities e.g. in this case 

                <field column="doc_id" template="salg_${salgrade.GRADE}" />

is a made up column and this doc_id values should be unique across all
entities. template clause is like transformation e.g. doc_id values are made
up by prefixing salg_ and values of ${salgrade.GRADE} in the first entity
section while in the second entity section, it is using different prefix and
different variable to make it Unique.

schema.xml have       <uniqueKey>doc_id</uniqueKey>
and also add following :
   
      <field name="deptno" type="text_general" indexed="true" stored="true" 
required="false" /> 
      <field name="dname" type="text_general" indexed="true" stored="true" 
/> 
      <field name="loc" type="text_general" indexed="true" stored="true"  /> 
      <field name="ename" type="text_general" indexed="true" stored="true"
multiValued="true" /> 
      <field name="job" type="text_general" indexed="true" stored="true" 
multiValued="true"/> 
   
   <field name="grade" type="text_general" indexed="true" stored="true" 
required="false" /> 
   <field name="losal" type="text_general" indexed="true" stored="true"  /> 
   <field name="hisal" type="text_general" indexed="true" stored="true"  />

   <field name="doc_id" type="string" indexed="false" stored="false"  />




  <document>
      <entity name="salgrade"   transformer="TemplateTransformer" 
query="select grade,losal,hisal from salgrade" >
                <field column="doc_id" template="salg_${salgrade.GRADE}" />
                <field column="GRADE" name="grade"  />
                <field column="LOSAL" name="losal" />
                <field column="HISAL" name="hisal" />
      </entity>
    <entity name="mydept"  transformer="TemplateTransformer"  query="select
deptno,dname,loc from dept">
            <field column="doc_id" template="myd_${mydept.DEPTNO}" />  
            <field column="DEPTNO" name="deptno"  />
            <field column="DNAME" name="dname" />
            <field column="LOC" name="loc" />
            
            <entity name="myemp" transformer="TemplateTransformer" 
query="select ename,job from emp where deptno=${mydept.DEPTNO} " >
               <field column="ENAME" name="ename" />
               <field column="JOB" name="job" />
            </entity>
    </entity>
    
  </document>




--
View this message in context: http://lucene.472066.n3.nabble.com/How-do-I-add-another-unrelated-query-results-to-solr-index-tp4128932p4129678.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: How do I add another unrelated query results to solr index

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi,

It is possible but remove rootEntity="true" from entity declarations.




On Thursday, April 3, 2014 10:29 PM, sanjay92 <sa...@hotmail.com> wrote:
Hi,
How do I add two different queries into one single index.
e..g.
I have added following
      <entity name="salgrade" rootEntity="true"  query="select
grade,losal,hisal from salgrade" >
                <field column="GRADE" name="grade" />
                <field column="LOSAL" name="losal" />
                <field column="HISAL" name="hisal" />
      </entity>

But when I query, I dont see any data from salgrade table.
I have also tried another document tag but that also did not work as
expected.
Is it possible ?

<dataConfig>
  <dataSource type="JdbcDataSource"
              driver="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@mydb:1521:SID"
              user="****"
              password="****"  />
  <document>
      <entity name="salgrade" rootEntity="true"  query="select
grade,losal,hisal from salgrade" >
                <field column="GRADE" name="grade" />
                <field column="LOSAL" name="losal" />
                <field column="HISAL" name="hisal" />
      </entity>
    <entity name="mydept"  rootEntity="true" query="select deptno,dname,loc
from dept">
            <field column="DEPTNO" name="deptno" />
            <field column="DNAME" name="dname" />
            <field column="LOC" name="loc" />
            <entity name="myemp" query="select ename,job from emp where
deptno=${mydept.DEPTNO} " >
               <field column="ENAME" name="ename" />
               <field column="JOB" name="job" />
            </entity>
    </entity>
    
  </document>
  
</dataConfig>




--
View this message in context: http://lucene.472066.n3.nabble.com/How-do-I-add-another-unrelated-query-results-to-solr-index-tp4128932.html
Sent from the Solr - User mailing list archive at Nabble.com.