次のPostgresクエリを実行しています。2つの文字列間の距離を計算する
SELECT * FROM description WHERE levenshtein(desci, 'Description text?') <= 6 LIMIT 10;
私は上記のクエリを実行します。
public static boolean authQuestion(String question) throws SQLException{
boolean isDescAvailable = false;
Connection connection = null;
try {
connection = DbRes.getConnection();
String query = "SELECT * FROM description WHERE levenshtein(desci, ?) <= 6";
PreparedStatement checkStmt = dbCon.prepareStatement(query);
checkStmt.setString(1, question);
ResultSet rs = checkStmt.executeQuery();
while (rs.next()) {
isDescAvailable = true;
}
} catch (URISyntaxException e1) {
e1.printStackTrace();
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
if (connection != null)
connection.close();
} finally {
if (connection != null)
connection.close();
}
return isDescAvailable;
}
Iは、入力テキストおよびデータベース内の既存の価値観の両方の間の編集距離を見つけたいです。私は60%の編集距離を持つすべてのデータを取得したい。上記のクエリは期待どおりに機能しません。 60%の類似性を含む行を取得するにはどうすればよいですか?
ここでJavaコードはほとんど無関係です。あなたはデータベースから得た結果は何ですか?あなたが期待している結果は何ですか? **あなたの質問を編集し、そのデータに基づいてサンプルデータと予想される出力を追加してください。 [**フォーマットされたテキスト**](http://stackoverflow.com/help/formatting)、[スクリーンショットなし](http://meta.stackoverflow.com/questions/285551/why-may-i-not -upload-images-of-code-on-so-asking-a-question/285557#285557) –
どのような考えですか?..... –