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 Каскевич Александр <ak...@prontosoft.by> on 2013/04/22 10:44:09 UTC

ranking score by fields

Hi.
I want to make subject but don't know exactly how can I do it.
Example.
I have index with field1, field2, field3.
I make a query like:
(field1:apache solr) OR (field2:apache solr) OR (field3:apache solr)
And I want to know: is it found this doc by field1 or by field2 or by field3?

I try to make like this: (field1:apache solr)^100 OR (field2:apache solr)^10 OR (field3:apache solr)^1
But the problem is that I don't know range, minimum and maximum value of score for each field.
With other types of similarities (BM25 or othres) same situation.
I cant find information about this in manual.

Else, I try to use Relevance Functions, f.e. "termfreq" but it work only with terms, not with phrases, like "apache solr".

May be I miss something or you have other idea to do this?
And else, I am not a java programmer and best way for me don't  write any plugins for solr.

Thanks.
Alex.

Re: ranking score by fields

Posted by Majirus FANSI <ma...@gmail.com>.
Hi Alex,
Back to your original requirement,  I think you can do the job at the
client side.  As Erik noted,  highlighter component can help. You are right
it marks terms but not search text. But analyzing the search text with the
appropriate analyzer will give you the terms of your text as used by the
highlighter component.
Hope this helps.
Cheers,

Maj


On 24 April 2013 16:02, Каскевич Александр <ak...@prontosoft.by> wrote:

> Highlighter doesn’t help me. It mark terms but not search text.
> F.e. I have doc with field1="apache lucene", field2="apache solr". I
> search "apache solr" with "AND" default option. I found this doc with
> highlighted field1="<em>apache</em> lucene". This is bad result for me.
>
> Look I want to do something like this:
>
> Search text: apache solr
> RESULT:
> Found in field1
> Doc1
> Doc2
> Doc3
> ...
> Found in field2
> Doc101
> Doc102
> Doc103
> ...
>
> Search result have two (or more) parts. Each part sorted by other field
> f.e. by field date desc.
>
> It mean I need make right sort and I need some flag to insert "Found in
> field2" text.
>
> I try
> q=apache solr
> &fl=field1, field2, score, val1:$q1, val2:$q2
> &defType=dismax &qf=field1^1000 field2^1
> &q1={!dismax qf=field1 v='apache solr'}
> &q2={!dismax qf=field2 v='apache solr'}
>
> Now I have flags: val1>0 - found in field1
> But now I have problem with sort: I cant use val1, val2 in sort :(.
>
> And now my questions:
> 1. have I posibility use my custom fields val1, val2 in sort? With
> formula. Or params $q1, $q2?
> 2. may be I have posibility set score by formula at qurey-time?
> 3. your variant?
>
> Thanks.
> Alex.
>
> -----Original Message-----
> From: Erick Erickson [mailto:erickerickson@gmail.com]
> Sent: Tuesday, April 23, 2013 1:53 AM
> To: solr-user@lucene.apache.org
> Subject: Re: ranking score by fields
>
> You can sometimes use the highlighter component to do this, but it's a
> little tricky...
>
> But note your syntax isn't doing what you expect.
> (field1:apache solr) parses as field1:apache defaultfield:solr. You want
> field1:(apache solr)....
>
> &debug=all is your friend for these kinds of things, especially the parsed
> query section....
>
> Best
> Erick
>
> On Mon, Apr 22, 2013 at 4:44 AM, Каскевич Александр <
> akaskevich@prontosoft.by> wrote:
> > Hi.
> > I want to make subject but don't know exactly how can I do it.
> > Example.
> > I have index with field1, field2, field3.
> > I make a query like:
> > (field1:apache solr) OR (field2:apache solr) OR (field3:apache solr)
> > And I want to know: is it found this doc by field1 or by field2 or by
> field3?
> >
> > I try to make like this: (field1:apache solr)^100 OR (field2:apache
> > solr)^10 OR (field3:apache solr)^1 But the problem is that I don't know
> range, minimum and maximum value of score for each field.
> > With other types of similarities (BM25 or othres) same situation.
> > I cant find information about this in manual.
> >
> > Else, I try to use Relevance Functions, f.e. "termfreq" but it work only
> with terms, not with phrases, like "apache solr".
> >
> > May be I miss something or you have other idea to do this?
> > And else, I am not a java programmer and best way for me don't  write
> any plugins for solr.
> >
> > Thanks.
> > Alex.
>

RE: ranking score by fields

Posted by Каскевич Александр <ak...@prontosoft.by>.
Highlighter doesn’t help me. It mark terms but not search text. 
F.e. I have doc with field1="apache lucene", field2="apache solr". I search "apache solr" with "AND" default option. I found this doc with highlighted field1="<em>apache</em> lucene". This is bad result for me.

Look I want to do something like this:

Search text: apache solr
RESULT:
Found in field1
Doc1
Doc2
Doc3
...
Found in field2 
Doc101
Doc102
Doc103
...

Search result have two (or more) parts. Each part sorted by other field f.e. by field date desc.

It mean I need make right sort and I need some flag to insert "Found in field2" text.

I try 
q=apache solr
&fl=field1, field2, score, val1:$q1, val2:$q2
&defType=dismax &qf=field1^1000 field2^1
&q1={!dismax qf=field1 v='apache solr'}
&q2={!dismax qf=field2 v='apache solr'}

Now I have flags: val1>0 - found in field1
But now I have problem with sort: I cant use val1, val2 in sort :(.

And now my questions:
1. have I posibility use my custom fields val1, val2 in sort? With formula. Or params $q1, $q2?
2. may be I have posibility set score by formula at qurey-time?
3. your variant?

Thanks.
Alex.

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: Tuesday, April 23, 2013 1:53 AM
To: solr-user@lucene.apache.org
Subject: Re: ranking score by fields

You can sometimes use the highlighter component to do this, but it's a little tricky...

But note your syntax isn't doing what you expect.
(field1:apache solr) parses as field1:apache defaultfield:solr. You want field1:(apache solr)....

&debug=all is your friend for these kinds of things, especially the parsed query section....

Best
Erick

On Mon, Apr 22, 2013 at 4:44 AM, Каскевич Александр <ak...@prontosoft.by> wrote:
> Hi.
> I want to make subject but don't know exactly how can I do it.
> Example.
> I have index with field1, field2, field3.
> I make a query like:
> (field1:apache solr) OR (field2:apache solr) OR (field3:apache solr) 
> And I want to know: is it found this doc by field1 or by field2 or by field3?
>
> I try to make like this: (field1:apache solr)^100 OR (field2:apache 
> solr)^10 OR (field3:apache solr)^1 But the problem is that I don't know range, minimum and maximum value of score for each field.
> With other types of similarities (BM25 or othres) same situation.
> I cant find information about this in manual.
>
> Else, I try to use Relevance Functions, f.e. "termfreq" but it work only with terms, not with phrases, like "apache solr".
>
> May be I miss something or you have other idea to do this?
> And else, I am not a java programmer and best way for me don't  write any plugins for solr.
>
> Thanks.
> Alex.

Re: ranking score by fields

Posted by Erick Erickson <er...@gmail.com>.
You can sometimes use the highlighter component to do this, but it's a
little tricky...

But note your syntax isn't doing what you expect.
(field1:apache solr) parses as field1:apache defaultfield:solr. You want
field1:(apache solr)....

&debug=all is your friend for these kinds of things, especially the parsed query
section....

Best
Erick

On Mon, Apr 22, 2013 at 4:44 AM, Каскевич Александр
<ak...@prontosoft.by> wrote:
> Hi.
> I want to make subject but don't know exactly how can I do it.
> Example.
> I have index with field1, field2, field3.
> I make a query like:
> (field1:apache solr) OR (field2:apache solr) OR (field3:apache solr)
> And I want to know: is it found this doc by field1 or by field2 or by field3?
>
> I try to make like this: (field1:apache solr)^100 OR (field2:apache solr)^10 OR (field3:apache solr)^1
> But the problem is that I don't know range, minimum and maximum value of score for each field.
> With other types of similarities (BM25 or othres) same situation.
> I cant find information about this in manual.
>
> Else, I try to use Relevance Functions, f.e. "termfreq" but it work only with terms, not with phrases, like "apache solr".
>
> May be I miss something or you have other idea to do this?
> And else, I am not a java programmer and best way for me don't  write any plugins for solr.
>
> Thanks.
> Alex.