休止状態で FullTextFilters を FullTextQuery に追加しようとしていますが、メソッドしかありませんFullTextFilter.setParameter(String name, Object value)
検索するエンティティに基づいてクエリにフィルターを追加する柔軟で汎用的な関数を作成しようとしています.1つのパラメーターを持つものもあれば、フィルターに2つのパラメーターを持つものもあるため、にメソッドを追加したいと思いFullTextFilterImpl
ます。setParameters(String[] names, String[] value)
ここで、すべてのパラメーターの名前と、おそらく各パラメーターの値の多次元配列を渡して、現在のコードを変換できます
If( "checking which entity it is"){
fullTextQuery.enableFullTextFilter("FilterName").setParameter("firstFilter", "val1").setParameter("secondFilter", "val2");
}
else if("this entity's filter only has one parameter"){
fullTextQuery.enableFullTextFilter("FilterName").setParameter("firstFilter", "val1");
}
FullTextFilterImpl のサブクラスを作成して関数を入れようとしましたsetParameters
が、このコードの設定方法では、オブジェクトをFullTextQuery.enableFullTextFilter(filterName)
返し、そのFullTextFilter
オブジェクトで を呼び出す方法がわかりませんsetParameter()
。どうやってその途中で何かをするのかわかりませんsetParameters
編集: hibernate-search ソース コードをダウンロードし、次のメソッドを FullTextFilterImpl に追加しました。これらのチェックスタイルOnly one new line is allowed at the end of a file
エラー。休止状態のクイックビルドガイドに欠けているものはありますか?
public FullTextFilter setParameters(Map<String, List<String>> params){
for (String key : params.keySet()) {
List<String> values = params.get(key);
for(int i=0; i< values.size() ; i++){
parameters.put(key, values.get(i));
}
}
return this;
}