Skip to content

Commit

Permalink
Override lucene exception
Browse files Browse the repository at this point in the history
  • Loading branch information
noCharger committed Sep 11, 2023
1 parent 81c7b97 commit e722b95
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.StringHelper;
import org.opensearch.ExceptionsHelper;
import org.opensearch.OpenSearchException;
import org.opensearch.common.geo.GeoDistance;
import org.opensearch.common.geo.GeoPoint;
import org.opensearch.common.geo.GeoUtils;
Expand Down Expand Up @@ -111,6 +112,9 @@ public float tf(String field, String term) {
try {
return (float) scoreScript.getTermFrequency(TF, field, term);
} catch (Exception e) {
if (e instanceof UnsupportedOperationException && e.getMessage().equals("requires a TFIDFSimilarity (such as ClassicSimilarity)")) {
throw new OpenSearchException("requires a TFIDFSimilarity (such as [BM25] Similarity) in OpenSearch", e);
}
throw ExceptionsHelper.convertToOpenSearchException(e);
}
}
Expand Down

0 comments on commit e722b95

Please sign in to comment.