lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barkha <>
Subject posted query in forums as well as mailing list
Date Tue, 22 Jun 2010 13:19:31 GMT
Hello Guys,

i'm a new bea to solr and i've been trying to achieve one of my 
requirements which is described as under.

-> i've 2 tables in mysql db.i.e. (1) question_answer with fields 
id(PK),question,answer,notes etc in it
                  (2) question_keywords with fields 
id(PK),question_id(FK that references PK i.e. id of 
question_answer),keyword(1 question_id can have multiple keywords),score etc

-> Here i'm fetching the data from both the tables through solr and for 
that i did some changes in schema.xml,solr-config.xml and 
data-config.xml(that is referred by DataImportHandler specified in 
solr-config.xml) that lies under apache-solr-nightly/example/solr/conf 

-> in solr-config.xml i've specified Data Import Handler with this way,

<requestHandler name="/dataimport" 
    <lst name="defaults">
      <str name="config">data-config.xml</str>

-> in data-config.xml i've specified,

    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost/testdb" user="root" password=""/>
    <document name="solrtest">
        <entity name="question_answer" query="select * from 
            <field column="id" name="id" />
            <field column="question" name="question" />
            <field column="answer" name="answer" />        
            <entity name="question_keywords" query="select keyword, 
score from question_keywords where question_id='${}'">
                <field name="keyword" column="keyword" />
                <field name="score" column="score" />

-> in schema.xml,i've specified the following fields


   <field name="id" type="string" indexed="true" stored="true" 
required="true" />
   <field name="question" type="text" indexed="true" stored="true" 
   <field name="answer" type="text" indexed="true" stored="true" 
required="true" />
   <field name="keyword" type="text" indexed="true" stored="true" 
required="true" />
   <field name="score" type="integer" indexed="true" stored="true" 
required="true" />



 <solrQueryParser defaultOperator="OR"/>

-> Then i'm running start.jar given in example folder.and doing 
full-import by hitting this 

-> Here my requirement is...

i'm passing 1 question like "My baby has a nappy rash,what should I do?" 
in search query string by hitting this url : 
http://localhost:8983/solr/admin/ and pressing search button,

Then solr parses the string and matching the key words in 
question_keywords table and returns all the keywords with the matching 
question_id present in question_answer as i kept by default search field 
as a keyword,i'm getting the result in xml format with this 

here the current scenario is like this,

- if any 1 keyword matches with any of the keywords against question ids 
present in question_keywords and question_answer table,then it returns 
all the keywords that references the same instead of fetching all 
the keywords i need to fetch the keywords that are matching with the 
question passed as a search query string with its score references the 
same keyword.

-> and also i wanna do the sum of the score for the keywords that are 
fetched with different ids.and wanna return the result in form of 
question_id with the highest score among all the results(keywords with 
its score and question_id).

so How can i do this?

please somebody help as its too urgent,

desperately waiting for any reply.

Barkha Jasani

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message