Skip to content

Commit

Permalink
Move TermAndBoost back to its original location. (#12366)
Browse files Browse the repository at this point in the history
PR #12169 accidentally moved the `TermAndBoost` class to a different location,
which would break custom sub-classes of `QueryBuilder`. This commit moves it
back to its original location.
  • Loading branch information
jpountz authored Jun 14, 2023
1 parent 65447c8 commit a8baa47
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.util;
package org.apache.lucene.analysis.synonym.word2vec;

import org.apache.lucene.util.BytesRef;

/** Wraps a term and boost */
public class TermAndBoost {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.TermAndBoost;

/**
* Applies single-token synonyms from a Word2Vec trained network to an incoming {@link TokenStream}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TermAndBoost;
import org.apache.lucene.util.hnsw.HnswGraphBuilder;
import org.apache.lucene.util.hnsw.HnswGraphSearcher;
import org.apache.lucene.util.hnsw.NeighborQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TermAndBoost;
import org.apache.lucene.util.TermAndVector;
import org.junit.Test;

Expand Down
14 changes: 14 additions & 0 deletions lucene/core/src/java/org/apache/lucene/util/QueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ public class QueryBuilder {
protected boolean enableGraphQueries = true;
protected boolean autoGenerateMultiTermSynonymsPhraseQuery = false;

/** Wraps a term and boost */
public static class TermAndBoost {
/** the term */
public final BytesRef term;
/** the boost */
public final float boost;

/** Creates a new TermAndBoost */
public TermAndBoost(BytesRef term, float boost) {
this.term = BytesRef.deepCopyOf(term);
this.boost = boost;
}
}

/** Creates a new QueryBuilder using the given analyzer. */
public QueryBuilder(Analyzer analyzer) {
this.analyzer = analyzer;
Expand Down

0 comments on commit a8baa47

Please sign in to comment.