私はいくつかの Solr カスタム クエリ コンポーネントを作成しています。各コンポーネントは、さまざまな種類のクエリを実行します。
- コンポーネント A: クエリ フィールド A でグループ化します。
- コンポーネント B: 別のフィールド B でグループ化を行います
各コンポーネントは、結果のドキュメントを次のコンポーネントに送信します。
私の「プロセス」関数では、グループ化によって結果が設定された後、次のことを行います。
IndexSchema schema = searcher.getSchema();
DocListAndSet s = result.getDocListAndSet();
DocSet s3 = s.docSet;
DocIterator dit = s3.iterator()
while (dit.hasNext())
{
SolrDocument doc = new SolrDocument();
int docid = dit.nextDoc();
//float score = dit.score();<--This does not get the score
Document luceneDoc = searcher.doc(docid);//get the document using the doc id
for( Fieldable field : luceneDoc.getFields())
{
SchemaField sf = schema.getField( field.name() );
doc.addField( field.name(), sf.getType().toObject( field ) );
......
}
次に、Set を反復処理して SolrDocument を作成します。
SolrDocumentes は SolDocumentList に入力され、次のコンポーネントに送信されます。
rb.req.getContext().put("TAG", list);
「スコア」SolrDocument というフィールドも追加したいと思います。このフィールドには実際のスコアが含まれます。私は以下を使用してスコアを取得しようとしました:
float score = dit.score()
しかし、上記はドキュメントのスコアを取得しません。ドキュメント ID を使用してドキュメントの「スコア」を取得するにはどうすればよいですか?