You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Federico Pici <ak...@libero.it.INVALID> on 2019/05/08 14:45:58 UTC

About custom score using Solr8/Lucene8

Hi,

i was trying to implement custom score inside my solr8 instance.
On google i found some examples, all focused on using CustomScoreProvider and CustomScoreQuery classes. This classes have been removed in Solr8/Lucene8 
and, from Lucene 8 changeling, i saw a developer /contributor saying to use FunctionScoreQuery.

Googling around was unsuccessful as i found no example, so i have no clue from where to start from

I think i have a very basic need. Generate a score from field in  documents using logic completely unrelated with query itself.

The only way available (until any clue…) is using org.apache.solr.search.ValueSourceParser


Is there any example, at least to understand how to start a minimal basic project?

Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: About custom score using Solr8/Lucene8

Posted by Federico Pici <ak...@libero.it.INVALID>.
Hello Mikhail,
yes i did. I read all the page at https://issues.apache.org/jira/browse/LUCENE-8099 <https://issues.apache.org/jira/browse/LUCENE-8099>

I still do not understand where/how to start to write a class to be embedded in solr8. All
available example since 2012 where written around CustomScoreQuery/CustomScoreProvider.

I really don’t know how to setup a minimal project to implement custom scoring in solr8/lucene8 using FunctionScoreQuery

> Il giorno 8 mag 2019, alle ore 22:15, Mikhail Khludnev <mk...@apache.org> ha scritto:
> 
> Hello.
> 
> Have you checked the fourth item at
> http://lucene.apache.org/core/8_0_0/MIGRATE.html ?
> 
> On Wed, May 8, 2019 at 5:46 PM Federico Pici <ak...@libero.it.invalid>
> wrote:
> 
>> Hi,
>> 
>> i was trying to implement custom score inside my solr8 instance.
>> On google i found some examples, all focused on using CustomScoreProvider
>> and CustomScoreQuery classes. This classes have been removed in
>> Solr8/Lucene8
>> and, from Lucene 8 changeling, i saw a developer /contributor saying to
>> use FunctionScoreQuery.
>> 
>> Googling around was unsuccessful as i found no example, so i have no clue
>> from where to start from
>> 
>> I think i have a very basic need. Generate a score from field in
>> documents using logic completely unrelated with query itself.
>> 
>> The only way available (until any clue…) is using
>> org.apache.solr.search.ValueSourceParser
>> 
>> 
>> Is there any example, at least to understand how to start a minimal basic
>> project?
>> 
>> Thanks
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>> 
>> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev


Re: About custom score using Solr8/Lucene8

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello.

Have you checked the fourth item at
http://lucene.apache.org/core/8_0_0/MIGRATE.html ?

On Wed, May 8, 2019 at 5:46 PM Federico Pici <ak...@libero.it.invalid>
wrote:

> Hi,
>
> i was trying to implement custom score inside my solr8 instance.
> On google i found some examples, all focused on using CustomScoreProvider
> and CustomScoreQuery classes. This classes have been removed in
> Solr8/Lucene8
> and, from Lucene 8 changeling, i saw a developer /contributor saying to
> use FunctionScoreQuery.
>
> Googling around was unsuccessful as i found no example, so i have no clue
> from where to start from
>
> I think i have a very basic need. Generate a score from field in
> documents using logic completely unrelated with query itself.
>
> The only way available (until any clue…) is using
> org.apache.solr.search.ValueSourceParser
>
>
> Is there any example, at least to understand how to start a minimal basic
> project?
>
> Thanks
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

-- 
Sincerely yours
Mikhail Khludnev

Re: About custom score using Solr8/Lucene8

Posted by Michael Sokolov <ms...@gmail.com>.
You should think of DoubleValuesSource as a factory for DoubleValues.
Usually a factory will be immutable - you set it up and then it
produces per-leaf DoubleValues. So I don't really understand what
you're saying about state there.  Regarding the DoubleValues, which is
an iterator, yes it definitely has state: it has to keep track of
which document it is positioned on (if any). I think the order of
operations is as you listed them.


On Tue, Jul 7, 2020 at 1:11 PM Vincenzo D'Amore <v....@gmail.com> wrote:
>
> Thanks Michael,
> if I understand correctly the DoubleValuesSource is stateful.
> When getValues is called if scores is null an internal state true/false is
> saved.
> This state should be returned by needsScores method.
> Is this correct?
>
> As far as I understood, the same thing happens to the DoubleValue object
> returned by the getValues() method.
> DoubleValue object has an internal state which depends from advanceExact()
> method.
> In other words, DoubleValue.doubleValue() returns a value produced after
> the call of advanceExact(int docId).
>
> Now the problem I have is understanding if DoubleValuesSource has to be
> stateful or has to store an state that should be available later.
> Or, on the other hand, understand if there is an order in the methods calls
> (first getValues then needsScores, first advanceExact then doubleValue).
> Don't you agree?
>
>
> On Mon, Jul 6, 2020 at 4:58 PM Michael Sokolov <ms...@gmail.com> wrote:
>
> > That controls whether  getValues(LeafReaderContext ctx, DoubleValues
> > scores) gets a null scores parameter or not. You should say true only
> > if you need the text relevance scores computed by the Query's Scorer.
> >
> > On Mon, Jul 6, 2020 at 10:22 AM Vincenzo D'Amore <v....@gmail.com>
> > wrote:
> > >
> > > Hi Michael, thanks for answering my questions.
> > > Yes, I read, but I think that it not is enough.
> > >
> > > For make the things clearer, this is taken from the javadocs:
> > >
> > > abstract boolean needsScores() - Return true if document scores are
> > needed
> > > to calculate values
> > >
> > > So, I thought return true, because yes, I need to calculate the scores
> > for
> > > my custom implementations.
> > > Anyway, I should remember that the wrong way always seems more reasonable
> > > :) , and googling around for:
> > >
> > > "boolean needsScores" "DoubleValuesSource" site:github.com
> > >
> > > I found that when there is explicit code many implementations returns
> > > directly: false.
> > >
> > > What does this mean? why and when should I return true or false?
> > >
> > >
> > > On Mon, Jul 6, 2020 at 2:50 PM Michael Sokolov <ms...@gmail.com>
> > wrote:
> > >
> > > > Did you read the DoubleValuesSource javadocs, and find they weren't
> > enough?
> > > >
> > > > On Sun, Jul 5, 2020 at 7:54 AM Vincenzo D'Amore <v....@gmail.com>
> > > > wrote:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > Finally I have a custom DoubleValuesSource that gives the expected
> > > > results,
> > > > > but I'm a little worried about the lack of documentation.
> > > > >
> > > > > When you extend DoubleValuesSource there are a number of methods to
> > > > write,
> > > > > for some of them it is not clear what they do and why they need to be
> > > > > implemented.
> > > > > Here I've listed the mandatory methods:
> > > > >
> > > > >     public abstract DoubleValues getValues(LeafReaderContext var1,
> > > > > DoubleValues var2) throws IOException;
> > > > >     public abstract boolean needsScores()
> > > > >     public abstract DoubleValuesSource rewrite(IndexSearcher var1)
> > throws
> > > > > IOException;
> > > > >     public boolean isCacheable(LeafReaderContext ctx);
> > > > >     public abstract int hashCode();
> > > > >     public abstract boolean equals(Object var1);
> > > > >
> > > > > for some of them I could imagine why (hashCode() or equals()) but
> > what
> > > > > about the others?
> > > > > As said, I wrote an implementation of getValues that returns the
> > expected
> > > > > results (I've compared the results with the old version), but for
> > many
> > > > > methods I've just mimed (copied) the code found in other
> > implementations.
> > > > > So why does needsScores() always return false, how to implement
> > > > > correctly isCacheable() ?
> > > > > Anyone could write a short description of these methods and how they
> > > > > have to be implemented?
> > > > >
> > > > > Best regards,
> > > > > Vincenzo
> > > > >
> > > > > On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com>
> > > > wrote:
> > > > >
> > > > > > Hi all, I did few steps forward but still struggling in how read
> > the
> > > > field
> > > > > > value inside my custom DoubleValuesSource
> > > > > >
> > > > > >                     final CustomValuesSource valuesSource = new
> > > > > > CustomValuesSource(data, req.getSchema().getField(field));
> > > > > >                     return FunctionScoreQuery.boostByValue(query,
> > > > > > valuesSource);
> > > > > >
> > > > > > CustomValuesSource extends DoubleValuesSource
> > > > > >
> > > > > > But, if I did right, I'm struggling with the getValues code.
> > > > > >
> > > > > > public DoubleValues getValues(LeafReaderContext ctx, DoubleValues
> > > > scores)
> > > > > > throws IOException {
> > > > > >
> > > > > > The field I have to read is a binary field, and I can't find an
> > example
> > > > > > how to read a binary field from LeafReaderContext
> > > > > >
> > > > > > Any help appreciated.
> > > > > >
> > > > > > Best regards,
> > > > > > Vincenzo
> > > > > >
> > > > > > On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <
> > v.damore@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > >> Hi Mikhail, I was just trying to understand how to extend
> > > > > >> DoubleValuesSource class, now I'm looking around to find an
> > inspiring
> > > > > >> example...
> > > > > >>
> > > > > >> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mkhl@apache.org
> > >
> > > > wrote:
> > > > > >>
> > > > > >>> Hi, Vincenzo.
> > > > > >>>
> > > > > >>> Have you tried to implement DoubleValuesSource ?
> > > > > >>>
> > > > > >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <
> > v.damore@gmail.com>
> > > > > >>> wrote:
> > > > > >>>
> > > > > >>> > Again, @Federico Pici or anybody, did you figure out how to
> > > > > >>> > port CustomScoreQuery in Solr8?
> > > > > >>> >
> > > > > >>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> > > > > >>> >
> > > > > >>> > > @Federico Pici, did you figure out on how to produce
> > customized
> > > > > >>> score in
> > > > > >>> > > Solr
> > > > > >>> > > 8?
> > > > > >>> > >
> > > > > >>> > >
> > > > > >>> > >
> > > > > >>> > > --
> > > > > >>> > > Sent from:
> > > > > >>> > >
> > > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> > > > > >>> > >
> > > > > >>> > >
> > > > ---------------------------------------------------------------------
> > > > > >>> > > To unsubscribe, e-mail:
> > java-user-unsubscribe@lucene.apache.org
> > > > > >>> > > For additional commands, e-mail:
> > > > java-user-help@lucene.apache.org
> > > > > >>> > >
> > > > > >>> > >
> > > > > >>> >
> > > > > >>> > --
> > > > > >>> > Vincenzo D'Amore
> > > > > >>> >
> > > > > >>>
> > > > > >>>
> > > > > >>> --
> > > > > >>> Sincerely yours
> > > > > >>> Mikhail Khludnev
> > > > > >>>
> > > > > >>
> > > > > >>
> > > > > >> --
> > > > > >> Vincenzo D'Amore
> > > > > >>
> > > > > >>
> > > > > >
> > > > > > --
> > > > > > Vincenzo D'Amore
> > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > Vincenzo D'Amore
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > > >
> > > >
> > >
> > > --
> > > Vincenzo D'Amore
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
> --
> Vincenzo D'Amore

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Thanks Michael,
if I understand correctly the DoubleValuesSource is stateful.
When getValues is called if scores is null an internal state true/false is
saved.
This state should be returned by needsScores method.
Is this correct?

As far as I understood, the same thing happens to the DoubleValue object
returned by the getValues() method.
DoubleValue object has an internal state which depends from advanceExact()
method.
In other words, DoubleValue.doubleValue() returns a value produced after
the call of advanceExact(int docId).

Now the problem I have is understanding if DoubleValuesSource has to be
stateful or has to store an state that should be available later.
Or, on the other hand, understand if there is an order in the methods calls
(first getValues then needsScores, first advanceExact then doubleValue).
Don't you agree?


On Mon, Jul 6, 2020 at 4:58 PM Michael Sokolov <ms...@gmail.com> wrote:

> That controls whether  getValues(LeafReaderContext ctx, DoubleValues
> scores) gets a null scores parameter or not. You should say true only
> if you need the text relevance scores computed by the Query's Scorer.
>
> On Mon, Jul 6, 2020 at 10:22 AM Vincenzo D'Amore <v....@gmail.com>
> wrote:
> >
> > Hi Michael, thanks for answering my questions.
> > Yes, I read, but I think that it not is enough.
> >
> > For make the things clearer, this is taken from the javadocs:
> >
> > abstract boolean needsScores() - Return true if document scores are
> needed
> > to calculate values
> >
> > So, I thought return true, because yes, I need to calculate the scores
> for
> > my custom implementations.
> > Anyway, I should remember that the wrong way always seems more reasonable
> > :) , and googling around for:
> >
> > "boolean needsScores" "DoubleValuesSource" site:github.com
> >
> > I found that when there is explicit code many implementations returns
> > directly: false.
> >
> > What does this mean? why and when should I return true or false?
> >
> >
> > On Mon, Jul 6, 2020 at 2:50 PM Michael Sokolov <ms...@gmail.com>
> wrote:
> >
> > > Did you read the DoubleValuesSource javadocs, and find they weren't
> enough?
> > >
> > > On Sun, Jul 5, 2020 at 7:54 AM Vincenzo D'Amore <v....@gmail.com>
> > > wrote:
> > > >
> > > > Hi all,
> > > >
> > > > Finally I have a custom DoubleValuesSource that gives the expected
> > > results,
> > > > but I'm a little worried about the lack of documentation.
> > > >
> > > > When you extend DoubleValuesSource there are a number of methods to
> > > write,
> > > > for some of them it is not clear what they do and why they need to be
> > > > implemented.
> > > > Here I've listed the mandatory methods:
> > > >
> > > >     public abstract DoubleValues getValues(LeafReaderContext var1,
> > > > DoubleValues var2) throws IOException;
> > > >     public abstract boolean needsScores()
> > > >     public abstract DoubleValuesSource rewrite(IndexSearcher var1)
> throws
> > > > IOException;
> > > >     public boolean isCacheable(LeafReaderContext ctx);
> > > >     public abstract int hashCode();
> > > >     public abstract boolean equals(Object var1);
> > > >
> > > > for some of them I could imagine why (hashCode() or equals()) but
> what
> > > > about the others?
> > > > As said, I wrote an implementation of getValues that returns the
> expected
> > > > results (I've compared the results with the old version), but for
> many
> > > > methods I've just mimed (copied) the code found in other
> implementations.
> > > > So why does needsScores() always return false, how to implement
> > > > correctly isCacheable() ?
> > > > Anyone could write a short description of these methods and how they
> > > > have to be implemented?
> > > >
> > > > Best regards,
> > > > Vincenzo
> > > >
> > > > On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com>
> > > wrote:
> > > >
> > > > > Hi all, I did few steps forward but still struggling in how read
> the
> > > field
> > > > > value inside my custom DoubleValuesSource
> > > > >
> > > > >                     final CustomValuesSource valuesSource = new
> > > > > CustomValuesSource(data, req.getSchema().getField(field));
> > > > >                     return FunctionScoreQuery.boostByValue(query,
> > > > > valuesSource);
> > > > >
> > > > > CustomValuesSource extends DoubleValuesSource
> > > > >
> > > > > But, if I did right, I'm struggling with the getValues code.
> > > > >
> > > > > public DoubleValues getValues(LeafReaderContext ctx, DoubleValues
> > > scores)
> > > > > throws IOException {
> > > > >
> > > > > The field I have to read is a binary field, and I can't find an
> example
> > > > > how to read a binary field from LeafReaderContext
> > > > >
> > > > > Any help appreciated.
> > > > >
> > > > > Best regards,
> > > > > Vincenzo
> > > > >
> > > > > On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <
> v.damore@gmail.com>
> > > > > wrote:
> > > > >
> > > > >> Hi Mikhail, I was just trying to understand how to extend
> > > > >> DoubleValuesSource class, now I'm looking around to find an
> inspiring
> > > > >> example...
> > > > >>
> > > > >> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mkhl@apache.org
> >
> > > wrote:
> > > > >>
> > > > >>> Hi, Vincenzo.
> > > > >>>
> > > > >>> Have you tried to implement DoubleValuesSource ?
> > > > >>>
> > > > >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <
> v.damore@gmail.com>
> > > > >>> wrote:
> > > > >>>
> > > > >>> > Again, @Federico Pici or anybody, did you figure out how to
> > > > >>> > port CustomScoreQuery in Solr8?
> > > > >>> >
> > > > >>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> > > > >>> >
> > > > >>> > > @Federico Pici, did you figure out on how to produce
> customized
> > > > >>> score in
> > > > >>> > > Solr
> > > > >>> > > 8?
> > > > >>> > >
> > > > >>> > >
> > > > >>> > >
> > > > >>> > > --
> > > > >>> > > Sent from:
> > > > >>> > >
> > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> > > > >>> > >
> > > > >>> > >
> > > ---------------------------------------------------------------------
> > > > >>> > > To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> > > > >>> > > For additional commands, e-mail:
> > > java-user-help@lucene.apache.org
> > > > >>> > >
> > > > >>> > >
> > > > >>> >
> > > > >>> > --
> > > > >>> > Vincenzo D'Amore
> > > > >>> >
> > > > >>>
> > > > >>>
> > > > >>> --
> > > > >>> Sincerely yours
> > > > >>> Mikhail Khludnev
> > > > >>>
> > > > >>
> > > > >>
> > > > >> --
> > > > >> Vincenzo D'Amore
> > > > >>
> > > > >>
> > > > >
> > > > > --
> > > > > Vincenzo D'Amore
> > > > >
> > > > >
> > > >
> > > > --
> > > > Vincenzo D'Amore
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
> > --
> > Vincenzo D'Amore
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Michael Sokolov <ms...@gmail.com>.
That controls whether  getValues(LeafReaderContext ctx, DoubleValues
scores) gets a null scores parameter or not. You should say true only
if you need the text relevance scores computed by the Query's Scorer.

On Mon, Jul 6, 2020 at 10:22 AM Vincenzo D'Amore <v....@gmail.com> wrote:
>
> Hi Michael, thanks for answering my questions.
> Yes, I read, but I think that it not is enough.
>
> For make the things clearer, this is taken from the javadocs:
>
> abstract boolean needsScores() - Return true if document scores are needed
> to calculate values
>
> So, I thought return true, because yes, I need to calculate the scores for
> my custom implementations.
> Anyway, I should remember that the wrong way always seems more reasonable
> :) , and googling around for:
>
> "boolean needsScores" "DoubleValuesSource" site:github.com
>
> I found that when there is explicit code many implementations returns
> directly: false.
>
> What does this mean? why and when should I return true or false?
>
>
> On Mon, Jul 6, 2020 at 2:50 PM Michael Sokolov <ms...@gmail.com> wrote:
>
> > Did you read the DoubleValuesSource javadocs, and find they weren't enough?
> >
> > On Sun, Jul 5, 2020 at 7:54 AM Vincenzo D'Amore <v....@gmail.com>
> > wrote:
> > >
> > > Hi all,
> > >
> > > Finally I have a custom DoubleValuesSource that gives the expected
> > results,
> > > but I'm a little worried about the lack of documentation.
> > >
> > > When you extend DoubleValuesSource there are a number of methods to
> > write,
> > > for some of them it is not clear what they do and why they need to be
> > > implemented.
> > > Here I've listed the mandatory methods:
> > >
> > >     public abstract DoubleValues getValues(LeafReaderContext var1,
> > > DoubleValues var2) throws IOException;
> > >     public abstract boolean needsScores()
> > >     public abstract DoubleValuesSource rewrite(IndexSearcher var1) throws
> > > IOException;
> > >     public boolean isCacheable(LeafReaderContext ctx);
> > >     public abstract int hashCode();
> > >     public abstract boolean equals(Object var1);
> > >
> > > for some of them I could imagine why (hashCode() or equals()) but what
> > > about the others?
> > > As said, I wrote an implementation of getValues that returns the expected
> > > results (I've compared the results with the old version), but for many
> > > methods I've just mimed (copied) the code found in other implementations.
> > > So why does needsScores() always return false, how to implement
> > > correctly isCacheable() ?
> > > Anyone could write a short description of these methods and how they
> > > have to be implemented?
> > >
> > > Best regards,
> > > Vincenzo
> > >
> > > On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com>
> > wrote:
> > >
> > > > Hi all, I did few steps forward but still struggling in how read the
> > field
> > > > value inside my custom DoubleValuesSource
> > > >
> > > >                     final CustomValuesSource valuesSource = new
> > > > CustomValuesSource(data, req.getSchema().getField(field));
> > > >                     return FunctionScoreQuery.boostByValue(query,
> > > > valuesSource);
> > > >
> > > > CustomValuesSource extends DoubleValuesSource
> > > >
> > > > But, if I did right, I'm struggling with the getValues code.
> > > >
> > > > public DoubleValues getValues(LeafReaderContext ctx, DoubleValues
> > scores)
> > > > throws IOException {
> > > >
> > > > The field I have to read is a binary field, and I can't find an example
> > > > how to read a binary field from LeafReaderContext
> > > >
> > > > Any help appreciated.
> > > >
> > > > Best regards,
> > > > Vincenzo
> > > >
> > > > On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <v....@gmail.com>
> > > > wrote:
> > > >
> > > >> Hi Mikhail, I was just trying to understand how to extend
> > > >> DoubleValuesSource class, now I'm looking around to find an inspiring
> > > >> example...
> > > >>
> > > >> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org>
> > wrote:
> > > >>
> > > >>> Hi, Vincenzo.
> > > >>>
> > > >>> Have you tried to implement DoubleValuesSource ?
> > > >>>
> > > >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
> > > >>> wrote:
> > > >>>
> > > >>> > Again, @Federico Pici or anybody, did you figure out how to
> > > >>> > port CustomScoreQuery in Solr8?
> > > >>> >
> > > >>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> > > >>> >
> > > >>> > > @Federico Pici, did you figure out on how to produce customized
> > > >>> score in
> > > >>> > > Solr
> > > >>> > > 8?
> > > >>> > >
> > > >>> > >
> > > >>> > >
> > > >>> > > --
> > > >>> > > Sent from:
> > > >>> > >
> > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> > > >>> > >
> > > >>> > >
> > ---------------------------------------------------------------------
> > > >>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > >>> > > For additional commands, e-mail:
> > java-user-help@lucene.apache.org
> > > >>> > >
> > > >>> > >
> > > >>> >
> > > >>> > --
> > > >>> > Vincenzo D'Amore
> > > >>> >
> > > >>>
> > > >>>
> > > >>> --
> > > >>> Sincerely yours
> > > >>> Mikhail Khludnev
> > > >>>
> > > >>
> > > >>
> > > >> --
> > > >> Vincenzo D'Amore
> > > >>
> > > >>
> > > >
> > > > --
> > > > Vincenzo D'Amore
> > > >
> > > >
> > >
> > > --
> > > Vincenzo D'Amore
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
> --
> Vincenzo D'Amore

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Hi Michael, thanks for answering my questions.
Yes, I read, but I think that it not is enough.

For make the things clearer, this is taken from the javadocs:

abstract boolean needsScores() - Return true if document scores are needed
to calculate values

So, I thought return true, because yes, I need to calculate the scores for
my custom implementations.
Anyway, I should remember that the wrong way always seems more reasonable
:) , and googling around for:

"boolean needsScores" "DoubleValuesSource" site:github.com

I found that when there is explicit code many implementations returns
directly: false.

What does this mean? why and when should I return true or false?


On Mon, Jul 6, 2020 at 2:50 PM Michael Sokolov <ms...@gmail.com> wrote:

> Did you read the DoubleValuesSource javadocs, and find they weren't enough?
>
> On Sun, Jul 5, 2020 at 7:54 AM Vincenzo D'Amore <v....@gmail.com>
> wrote:
> >
> > Hi all,
> >
> > Finally I have a custom DoubleValuesSource that gives the expected
> results,
> > but I'm a little worried about the lack of documentation.
> >
> > When you extend DoubleValuesSource there are a number of methods to
> write,
> > for some of them it is not clear what they do and why they need to be
> > implemented.
> > Here I've listed the mandatory methods:
> >
> >     public abstract DoubleValues getValues(LeafReaderContext var1,
> > DoubleValues var2) throws IOException;
> >     public abstract boolean needsScores()
> >     public abstract DoubleValuesSource rewrite(IndexSearcher var1) throws
> > IOException;
> >     public boolean isCacheable(LeafReaderContext ctx);
> >     public abstract int hashCode();
> >     public abstract boolean equals(Object var1);
> >
> > for some of them I could imagine why (hashCode() or equals()) but what
> > about the others?
> > As said, I wrote an implementation of getValues that returns the expected
> > results (I've compared the results with the old version), but for many
> > methods I've just mimed (copied) the code found in other implementations.
> > So why does needsScores() always return false, how to implement
> > correctly isCacheable() ?
> > Anyone could write a short description of these methods and how they
> > have to be implemented?
> >
> > Best regards,
> > Vincenzo
> >
> > On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com>
> wrote:
> >
> > > Hi all, I did few steps forward but still struggling in how read the
> field
> > > value inside my custom DoubleValuesSource
> > >
> > >                     final CustomValuesSource valuesSource = new
> > > CustomValuesSource(data, req.getSchema().getField(field));
> > >                     return FunctionScoreQuery.boostByValue(query,
> > > valuesSource);
> > >
> > > CustomValuesSource extends DoubleValuesSource
> > >
> > > But, if I did right, I'm struggling with the getValues code.
> > >
> > > public DoubleValues getValues(LeafReaderContext ctx, DoubleValues
> scores)
> > > throws IOException {
> > >
> > > The field I have to read is a binary field, and I can't find an example
> > > how to read a binary field from LeafReaderContext
> > >
> > > Any help appreciated.
> > >
> > > Best regards,
> > > Vincenzo
> > >
> > > On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <v....@gmail.com>
> > > wrote:
> > >
> > >> Hi Mikhail, I was just trying to understand how to extend
> > >> DoubleValuesSource class, now I'm looking around to find an inspiring
> > >> example...
> > >>
> > >> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org>
> wrote:
> > >>
> > >>> Hi, Vincenzo.
> > >>>
> > >>> Have you tried to implement DoubleValuesSource ?
> > >>>
> > >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
> > >>> wrote:
> > >>>
> > >>> > Again, @Federico Pici or anybody, did you figure out how to
> > >>> > port CustomScoreQuery in Solr8?
> > >>> >
> > >>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> > >>> >
> > >>> > > @Federico Pici, did you figure out on how to produce customized
> > >>> score in
> > >>> > > Solr
> > >>> > > 8?
> > >>> > >
> > >>> > >
> > >>> > >
> > >>> > > --
> > >>> > > Sent from:
> > >>> > >
> http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> > >>> > >
> > >>> > >
> ---------------------------------------------------------------------
> > >>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > >>> > > For additional commands, e-mail:
> java-user-help@lucene.apache.org
> > >>> > >
> > >>> > >
> > >>> >
> > >>> > --
> > >>> > Vincenzo D'Amore
> > >>> >
> > >>>
> > >>>
> > >>> --
> > >>> Sincerely yours
> > >>> Mikhail Khludnev
> > >>>
> > >>
> > >>
> > >> --
> > >> Vincenzo D'Amore
> > >>
> > >>
> > >
> > > --
> > > Vincenzo D'Amore
> > >
> > >
> >
> > --
> > Vincenzo D'Amore
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Michael Sokolov <ms...@gmail.com>.
Did you read the DoubleValuesSource javadocs, and find they weren't enough?

On Sun, Jul 5, 2020 at 7:54 AM Vincenzo D'Amore <v....@gmail.com> wrote:
>
> Hi all,
>
> Finally I have a custom DoubleValuesSource that gives the expected results,
> but I'm a little worried about the lack of documentation.
>
> When you extend DoubleValuesSource there are a number of methods to write,
> for some of them it is not clear what they do and why they need to be
> implemented.
> Here I've listed the mandatory methods:
>
>     public abstract DoubleValues getValues(LeafReaderContext var1,
> DoubleValues var2) throws IOException;
>     public abstract boolean needsScores()
>     public abstract DoubleValuesSource rewrite(IndexSearcher var1) throws
> IOException;
>     public boolean isCacheable(LeafReaderContext ctx);
>     public abstract int hashCode();
>     public abstract boolean equals(Object var1);
>
> for some of them I could imagine why (hashCode() or equals()) but what
> about the others?
> As said, I wrote an implementation of getValues that returns the expected
> results (I've compared the results with the old version), but for many
> methods I've just mimed (copied) the code found in other implementations.
> So why does needsScores() always return false, how to implement
> correctly isCacheable() ?
> Anyone could write a short description of these methods and how they
> have to be implemented?
>
> Best regards,
> Vincenzo
>
> On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com> wrote:
>
> > Hi all, I did few steps forward but still struggling in how read the field
> > value inside my custom DoubleValuesSource
> >
> >                     final CustomValuesSource valuesSource = new
> > CustomValuesSource(data, req.getSchema().getField(field));
> >                     return FunctionScoreQuery.boostByValue(query,
> > valuesSource);
> >
> > CustomValuesSource extends DoubleValuesSource
> >
> > But, if I did right, I'm struggling with the getValues code.
> >
> > public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores)
> > throws IOException {
> >
> > The field I have to read is a binary field, and I can't find an example
> > how to read a binary field from LeafReaderContext
> >
> > Any help appreciated.
> >
> > Best regards,
> > Vincenzo
> >
> > On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <v....@gmail.com>
> > wrote:
> >
> >> Hi Mikhail, I was just trying to understand how to extend
> >> DoubleValuesSource class, now I'm looking around to find an inspiring
> >> example...
> >>
> >> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org> wrote:
> >>
> >>> Hi, Vincenzo.
> >>>
> >>> Have you tried to implement DoubleValuesSource ?
> >>>
> >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
> >>> wrote:
> >>>
> >>> > Again, @Federico Pici or anybody, did you figure out how to
> >>> > port CustomScoreQuery in Solr8?
> >>> >
> >>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> >>> >
> >>> > > @Federico Pici, did you figure out on how to produce customized
> >>> score in
> >>> > > Solr
> >>> > > 8?
> >>> > >
> >>> > >
> >>> > >
> >>> > > --
> >>> > > Sent from:
> >>> > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> >>> > >
> >>> > > ---------------------------------------------------------------------
> >>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >>> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> >>> > >
> >>> > >
> >>> >
> >>> > --
> >>> > Vincenzo D'Amore
> >>> >
> >>>
> >>>
> >>> --
> >>> Sincerely yours
> >>> Mikhail Khludnev
> >>>
> >>
> >>
> >> --
> >> Vincenzo D'Amore
> >>
> >>
> >
> > --
> > Vincenzo D'Amore
> >
> >
>
> --
> Vincenzo D'Amore

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Hi all,

Finally I have a custom DoubleValuesSource that gives the expected results,
but I'm a little worried about the lack of documentation.

When you extend DoubleValuesSource there are a number of methods to write,
for some of them it is not clear what they do and why they need to be
implemented.
Here I've listed the mandatory methods:

    public abstract DoubleValues getValues(LeafReaderContext var1,
DoubleValues var2) throws IOException;
    public abstract boolean needsScores()
    public abstract DoubleValuesSource rewrite(IndexSearcher var1) throws
IOException;
    public boolean isCacheable(LeafReaderContext ctx);
    public abstract int hashCode();
    public abstract boolean equals(Object var1);

for some of them I could imagine why (hashCode() or equals()) but what
about the others?
As said, I wrote an implementation of getValues that returns the expected
results (I've compared the results with the old version), but for many
methods I've just mimed (copied) the code found in other implementations.
So why does needsScores() always return false, how to implement
correctly isCacheable() ?
Anyone could write a short description of these methods and how they
have to be implemented?

Best regards,
Vincenzo

On Sat, Jul 4, 2020 at 3:29 AM Vincenzo D'Amore <v....@gmail.com> wrote:

> Hi all, I did few steps forward but still struggling in how read the field
> value inside my custom DoubleValuesSource
>
>                     final CustomValuesSource valuesSource = new
> CustomValuesSource(data, req.getSchema().getField(field));
>                     return FunctionScoreQuery.boostByValue(query,
> valuesSource);
>
> CustomValuesSource extends DoubleValuesSource
>
> But, if I did right, I'm struggling with the getValues code.
>
> public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores)
> throws IOException {
>
> The field I have to read is a binary field, and I can't find an example
> how to read a binary field from LeafReaderContext
>
> Any help appreciated.
>
> Best regards,
> Vincenzo
>
> On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <v....@gmail.com>
> wrote:
>
>> Hi Mikhail, I was just trying to understand how to extend
>> DoubleValuesSource class, now I'm looking around to find an inspiring
>> example...
>>
>> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org> wrote:
>>
>>> Hi, Vincenzo.
>>>
>>> Have you tried to implement DoubleValuesSource ?
>>>
>>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
>>> wrote:
>>>
>>> > Again, @Federico Pici or anybody, did you figure out how to
>>> > port CustomScoreQuery in Solr8?
>>> >
>>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
>>> >
>>> > > @Federico Pici, did you figure out on how to produce customized
>>> score in
>>> > > Solr
>>> > > 8?
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > Sent from:
>>> > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>>> > >
>>> > > ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> > > For additional commands, e-mail: java-user-help@lucene.apache.org
>>> > >
>>> > >
>>> >
>>> > --
>>> > Vincenzo D'Amore
>>> >
>>>
>>>
>>> --
>>> Sincerely yours
>>> Mikhail Khludnev
>>>
>>
>>
>> --
>> Vincenzo D'Amore
>>
>>
>
> --
> Vincenzo D'Amore
>
>

-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Hi all, I did few steps forward but still struggling in how read the field
value inside my custom DoubleValuesSource

                    final CustomValuesSource valuesSource = new
CustomValuesSource(data, req.getSchema().getField(field));
                    return FunctionScoreQuery.boostByValue(query,
valuesSource);

CustomValuesSource extends DoubleValuesSource

But, if I did right, I'm struggling with the getValues code.

public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores)
throws IOException {

The field I have to read is a binary field, and I can't find an example how
to read a binary field from LeafReaderContext

Any help appreciated.

Best regards,
Vincenzo

On Thu, Jul 2, 2020 at 1:19 PM Vincenzo D'Amore <v....@gmail.com> wrote:

> Hi Mikhail, I was just trying to understand how to extend
> DoubleValuesSource class, now I'm looking around to find an inspiring
> example...
>
> On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org> wrote:
>
>> Hi, Vincenzo.
>>
>> Have you tried to implement DoubleValuesSource ?
>>
>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
>> wrote:
>>
>> > Again, @Federico Pici or anybody, did you figure out how to
>> > port CustomScoreQuery in Solr8?
>> >
>> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
>> >
>> > > @Federico Pici, did you figure out on how to produce customized score
>> in
>> > > Solr
>> > > 8?
>> > >
>> > >
>> > >
>> > > --
>> > > Sent from:
>> > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> > > For additional commands, e-mail: java-user-help@lucene.apache.org
>> > >
>> > >
>> >
>> > --
>> > Vincenzo D'Amore
>> >
>>
>>
>> --
>> Sincerely yours
>> Mikhail Khludnev
>>
>
>
> --
> Vincenzo D'Amore
>
>

-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Hi Mikhail, I was just trying to understand how to extend
DoubleValuesSource class, now I'm looking around to find an inspiring
example...

On Thu, Jul 2, 2020 at 12:55 PM Mikhail Khludnev <mk...@apache.org> wrote:

> Hi, Vincenzo.
>
> Have you tried to implement DoubleValuesSource ?
>
> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com>
> wrote:
>
> > Again, @Federico Pici or anybody, did you figure out how to
> > port CustomScoreQuery in Solr8?
> >
> > On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
> >
> > > @Federico Pici, did you figure out on how to produce customized score
> in
> > > Solr
> > > 8?
> > >
> > >
> > >
> > > --
> > > Sent from:
> > > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
> > --
> > Vincenzo D'Amore
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>


-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Mikhail Khludnev <mk...@apache.org>.
Hi, Vincenzo.

Have you tried to implement DoubleValuesSource ?

On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v....@gmail.com> wrote:

> Again, @Federico Pici or anybody, did you figure out how to
> port CustomScoreQuery in Solr8?
>
> On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:
>
> > @Federico Pici, did you figure out on how to produce customized score in
> > Solr
> > 8?
> >
> >
> >
> > --
> > Sent from:
> > http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
> --
> Vincenzo D'Amore
>


-- 
Sincerely yours
Mikhail Khludnev

Re: About custom score using Solr8/Lucene8

Posted by Vincenzo D'Amore <v....@gmail.com>.
Again, @Federico Pici or anybody, did you figure out how to
port CustomScoreQuery in Solr8?

On Tue, Jul 23, 2019 at 1:05 AM Xiaofei <me...@xiaofei.ca> wrote:

> @Federico Pici, did you figure out on how to produce customized score in
> Solr
> 8?
>
>
>
> --
> Sent from:
> http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

-- 
Vincenzo D'Amore

Re: About custom score using Solr8/Lucene8

Posted by Xiaofei <me...@xiaofei.ca>.
@Federico Pici, did you figure out on how to produce customized score in Solr
8? 



--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org