Hi,
Fixed the issue with document and formatting.
My schema is like below.
     <fields>           <dynamicField name="Subject-Name-*" type="string" 
indexed="true" stored="true"/>                <dynamicField 
name="Subject-Mark-*" type="int" indexed="true" stored="true"/>    </fields>
My need is to search only three subject fields and boost those subjects which 
has a higher Mark(Mark can be in between 1 - 10).
Again Top subjects will get a higher boost than preceding one's.
Like if a search term is present in Subject-Name-1,Then it will get a higher 
boost than Subject-Name-2 and Subject-Name-3.
Similarly Subject-Mark-1 will get higher boost than Subject-Mark-2 and 
Subject-Mark-3.
To achieve this i am querying over subject fields and my query looks like 
below.  
      
q=+Economics+Geography&wt=xml&deftype=edismax&qf=Subject-Name-1+Subject-Name-2+Subject-Name-3&bq=Subject-Name-1%3AEconomics%3BGeography^50.0+Subject-Mark-1%3A20^90.0+Subject-Mark-1%3A9^80.0+Subject-Mark-1%3A8^70.0+Subject-Mark-1%3A7^60.0+Subject-Name-2%3AEconomics%3BGeography^45.0+Subject-Mark-2%3A20^90.0+Subject-Mark-2%3A9^80.0+Subject-Mark-2%3A8^70.0+Subject-Mark-2%3A7^60.0+Subject-Name-3%3AEconomics%3BGeography^40.0+Subject-Mark-3%3A20^90.0+Subject-Mark-3%3A9^80.0+Subject-Mark-3%3A8^70.0+Subject-Mark-3%3A7^60.0

If i am having four documents like below

    <doc>    <str name="Subject-Name-1">Economics</str>    <str 
name="Subject-Name-2">Geography</str>    <str 
name="Subject-Name-3">History</str>    <int name="Subject-Mark-1">7</int>    
<int name="Subject-Mark-2">7</int>    <int name="Subject-Mark-3">6</int>    
</doc>
        <doc>    <str name="Subject-Name-1">Economics</str>    <str 
name="Subject-Name-2">History</str>    <str 
name="Subject-Name-3">Geography</str>    <int name="Subject-Mark-1">8</int>    
<int name="Subject-Mark-2">8</int>    <int name="Subject-Mark-3">5</int>    
</doc>
        <doc>    <str name="Subject-Name-1">Economics</str>    <str 
name="Subject-Name-2">History</str>    <str 
name="Subject-Name-3">Geography</str>    <int name="Subject-Mark-1">9</int>    
<int name="Subject-Mark-2">6</int>    <int name="Subject-Mark-3">7</int>    
</doc>
        <doc>    <str name="Subject-Name-1">Economics</str>    <str 
name="Subject-Name-2">Mathematics</str>    <str 
name="Subject-Name-3">History</str>    <int name="Subject-Mark-1">7</int>    
<int name="Subject-Mark-2">7</int>    <int name="Subject-Mark-3">6</int>    
</doc>


then i am getting a higher score for last document which has only one of the 
search term !!!
But in my situation it is not applicable. My requirement is,if a document has 
only one term then they should get a lower score than the documents which are 
having both of the terms.
Is it happening because of idf(rarer terms give higher contribution to the 
total score) ?
Or there is something wrong with my query ?
Can anybody help me to achieve the desired output.
Thanks in advance


> Date: Thu, 7 Feb 2013 17:23:21 +0100
> From: jonas.birgan...@prisjakt.nu
> To: solr-user@lucene.apache.org
> Subject: Re: Calculate score according to another indexed field
> 
> On 2013-02-07 14:58, Pragyanshis Pattanaik wrote:
> > Hi,
> 
> Hi,
> 
> > My schema is like below
> > <fields>
> >      <field name="ProductId" type="int" indexed="true" stored="true" />
> >      <field name="ProductName" type="string" indexed="true" stored="true" 
> > required="true" />
> >      <field name="ProductDesription" type="string" indexed="true" 
> > stored="true" required="true" />
> >      <field name="ProductRating" type="int" indexed="true" stored="true" 
> > required="true" />
> > </fields>
> >
> > Product name will be passed as q parameter to solr.
> > Is there a way to affect score on the basis of "ProductRating" which is not 
> > passed as query parameter ?
> 
> You can use a boost function to achieve this.
> There are examples in the wiki: 
> <http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_change_the_score_of_a_document_based_on_the_.2Avalue.2A_of_a_field_.28say.2C_.22popularity.22.29>
> 
> A quick example:
> defType=dismax&qf=text&q=supervillians&bf=sqrt(ProductRating)
> 
> 
> Regards,
> -- 
> Jonas Birgander
                                          

Reply via email to