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 danielitos85 <da...@gmail.com> on 2013/08/30 15:57:29 UTC

Change the score of a document based on the *value* of a multifield using dismax

Hi guys,

I need to change the score of a document based on the value of a multifield.
I thoght that maybe I need to set boost in index-time (but I don't sure).
Now I explain you my situation:

- I'm usng solr4.4 
- I'm index data using dataimporthandler with rdbms
- my documents are a particular kind of places
- my field are places and their review and description
- my multifield is distance_place beacause each place (one place is a field)
has a lot of review or description

I'm tring with the following request but it return error "can not use
FieldCache on multivalued field: distance_place"

http://localhost:8983/solr/myCore/select?q={!boost b=distance_place v=$qq
defType=dismax}&qq=pizza&fl=*,score&qf=text_review+text_description

I'm thinking that if I set the boost at each review/description with the
value of the distance_place in index-time it is easy, but in this case I
don't know which is the right syntax to set the boost into db-dataimport.xml
file.

Please, Any suggests? 
Thanks in advance.




--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-using-dismax-tp4087503.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by danielitos85 <da...@gmail.com>.
Thanks a lot David. 
I will try it ;)





--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4088145.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
If you want to alter the score in a customized way based on indexed text data
on a per-value basis then index Lucene payloads, and use PayloadTermQuery. 
See the javadocs for PayloadTermQuery in particular and follow the
references.  This is a bit dated but read this:
http://searchhub.org/2009/08/05/getting-started-with-payloads/

You can get this done.  Almost anything is doable if you have sufficient
time and determination.

~ David



-----
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4088086.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by danielitos85 <da...@gmail.com>.
:(



--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4087666.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by Erick Erickson <er...@gmail.com>.
Whoa! You've suddenly changed from asking about querying
to DIH. I'll leave DIH to people who understand that way
better than I do.

As for the rest, you won't be able to boost by the values
even after you do get them in a multiValued field, so I think
you'll have problems as you try to carry this forward.

Best
Erick


On Sat, Aug 31, 2013 at 10:36 AM, danielitos85 <da...@gmail.com>wrote:

> Thanks Erick, but think if I have an simple float value and not distance.
>
> I have a situation like this:
>
> - id: 1
> - myText:  ["iphone", "ipad", "macbook"]
> - myFieldFloat: [3.4,2.1,5.3]
>
> I want to set the value of myFieldFloat at his respective myText.
>
> I tried this:
>
> <entity name="item"
> query="SELECT myText,
>                   myFloatValue
>             FROM myTable
>             WHERE myCondition" >
>
>       <field name="myText" column="myText" boost="${item.myFloatValue}" />
>
> but it return an error:
> org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config
> problem: For input string: "{$places.distance_place}"
>     at
>
> I also tried to set in my query a Cast, but the same error:
>
> SELECT myText,
>   CAST(myFloatValue AS DECIMAL(10,6)) as myFloatValue
>   FROM myTable
>  WHERE myCondition
>
> please, any suggests?
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4087663.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by danielitos85 <da...@gmail.com>.
Thanks Erick, but think if I have an simple float value and not distance.

I have a situation like this:

- id: 1
- myText:  ["iphone", "ipad", "macbook"]
- myFieldFloat: [3.4,2.1,5.3]

I want to set the value of myFieldFloat at his respective myText.

I tried this:

<entity name="item"
query="SELECT myText,
                  myFloatValue
            FROM myTable
            WHERE myCondition" >
      
      <field name="myText" column="myText" boost="${item.myFloatValue}" />

but it return an error: 
org.apache.solr.handler.dataimport.DataImportHandlerException: Data Config
problem: For input string: "{$places.distance_place}"
    at 

I also tried to set in my query a Cast, but the same error:

SELECT myText,
  CAST(myFloatValue AS DECIMAL(10,6)) as myFloatValue
  FROM myTable
 WHERE myCondition

please, any suggests?



--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4087663.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by Erick Erickson <er...@gmail.com>.
I'm guessing that you'd be best served by changing your
model a bit. It looks like you are somehow doing searches
that center on the airport and arrange businesses of various
types based on how far they are from the airport. But you're
collecting all the businesses in one solr document.

It would work much better, I think, to index each business
along with it's location see:
http://wiki.apache.org/solr/SpatialSearch

Now, assuming you're somehow expressing the concept
"find me businesses around airport X", you do a standard
search and boost by the distance between the airport and
the businesses. You can use a bbox filter query to keep
from calculating very many distances (also on the page
I linked to).

FWIW,
Erick


On Fri, Aug 30, 2013 at 2:47 PM, danielitos85 <da...@gmail.com>wrote:

> Ok, agree.
> I mean that I want to set a boost to each review/description (multifield)
> of
> the Places (multifield), and this boost is the corrispective value of the
> distance beetween the place and the particular kind of place that I have as
> document.
>
> Is it clear?
>
> I Try to explain again the situation:
>
>  - my document is a particular kind of Place (for example airport)
>  - my fields are all the text (review and description) of the places around
> the airport having a distance < 10 km.
>
> Now if I search for "pizza" solr return me the airport where there are a
> lot
> of terms "pizza" into review/description doesn't consider the distance. So
> I
> want to set a boost at each review/description based on the value of
> distance.
>
> Thanks in advance
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4087563.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by danielitos85 <da...@gmail.com>.
Ok, agree.
I mean that I want to set a boost to each review/description (multifield) of
the Places (multifield), and this boost is the corrispective value of the
distance beetween the place and the particular kind of place that I have as
document.

Is it clear?

I Try to explain again the situation:

 - my document is a particular kind of Place (for example airport)
 - my fields are all the text (review and description) of the places around
the airport having a distance < 10 km.

Now if I search for "pizza" solr return me the airport where there are a lot
of terms "pizza" into review/description doesn't consider the distance. So I
want to set a boost at each review/description based on the value of
distance.

Thanks in advance



--
View this message in context: http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-tp4087503p4087563.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Change the score of a document based on the *value* of a multifield using dismax

Posted by Erick Erickson <er...@gmail.com>.
bq: I need to change the score of a document based on the value of a
multifield

This is contradictory in the sense that there is no "value of a
multifield". That is,
which of the entries in a multiValued field is the "right" one to use?
There's no
syntax for doing a boost function on "the first thing in the field", or
"the third
thing in the field" etc.

So tell us a little more about distance_place and what you want to use it
for.
Boosting by distance has a much different syntax, see:
http://wiki.apache.org/solr/SpatialSearch#How_to_boost_closest_results

Best
Erick


On Fri, Aug 30, 2013 at 9:57 AM, danielitos85 <da...@gmail.com>wrote:

> Hi guys,
>
> I need to change the score of a document based on the value of a
> multifield.
> I thoght that maybe I need to set boost in index-time (but I don't sure).
> Now I explain you my situation:
>
> - I'm usng solr4.4
> - I'm index data using dataimporthandler with rdbms
> - my documents are a particular kind of places
> - my field are places and their review and description
> - my multifield is distance_place beacause each place (one place is a
> field)
> has a lot of review or description
>
> I'm tring with the following request but it return error "can not use
> FieldCache on multivalued field: distance_place"
>
> http://localhost:8983/solr/myCore/select?q={!boost b=distance_place v=$qq
> defType=dismax}&qq=pizza&fl=*,score&qf=text_review+text_description
>
> I'm thinking that if I set the boost at each review/description with the
> value of the distance_place in index-time it is easy, but in this case I
> don't know which is the right syntax to set the boost into
> db-dataimport.xml
> file.
>
> Please, Any suggests?
> Thanks in advance.
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Change-the-score-of-a-document-based-on-the-value-of-a-multifield-using-dismax-tp4087503.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>