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.dam...@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 <msoko...@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.dam...@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 <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 > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > > For additional commands, e-mail: java-user-h...@lucene.apache.org > > > > > > -- > Vincenzo D'Amore --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org