1 package org.apache.lucene.search.payloads;
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.io.Serializable;
20 import org.apache.lucene.search.Explanation;
23 * An abstract class that defines a way for Payload*Query instances to transform
24 * the cumulative effects of payload scores for a document.
26 * @see org.apache.lucene.search.payloads.PayloadTermQuery for more information
28 * @lucene.experimental This class and its derivations are experimental and subject to
32 public abstract class PayloadFunction implements Serializable {
35 * Calculate the score up to this point for this doc and field
36 * @param docId The current doc
37 * @param field The field
38 * @param start The start position of the matching Span
39 * @param end The end position of the matching Span
40 * @param numPayloadsSeen The number of payloads seen so far
41 * @param currentScore The current score so far
42 * @param currentPayloadScore The score for the current payload
43 * @return The new current Score
45 * @see org.apache.lucene.search.spans.Spans
47 public abstract float currentScore(int docId, String field, int start, int end, int numPayloadsSeen, float currentScore, float currentPayloadScore);
50 * Calculate the final score for all the payloads seen so far for this doc/field
51 * @param docId The current doc
52 * @param field The current field
53 * @param numPayloadsSeen The total number of payloads seen on this document
54 * @param payloadScore The raw score for those payloads
55 * @return The final score for the payloads
57 public abstract float docScore(int docId, String field, int numPayloadsSeen, float payloadScore);
59 public Explanation explain(int docId, int numPayloadsSeen, float payloadScore){
60 Explanation result = new Explanation();
61 result.setDescription("Unimpl Payload Function Explain");
67 public abstract int hashCode();
70 public abstract boolean equals(Object o);