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 <msoko...@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.dam...@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.dam...@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.dam...@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 <m...@apache.org>
> wrote:
> > >>
> > >>> Hi, Vincenzo.
> > >>>
> > >>> Have you tried to implement DoubleValuesSource ?
> > >>>
> > >>> On Thu, Jul 2, 2020 at 9:58 AM Vincenzo D'Amore <v.dam...@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 <m...@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-unsubscr...@lucene.apache.org
> > >>> > > For additional commands, e-mail:
> java-user-h...@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-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

-- 
Vincenzo D'Amore

Reply via email to