I am trying to port to HS 6.0 from 5.11 and have run into the following issue. Previously, in HS 5.11 I did the following to retrieve the score for each search result.
FullTextQuery fullTextQuery = createFullTextQuery(criteria);
fullTextQuery.setProjection(FullTextQuery.SCORE, FullTextQuery.THIS, FullTextQuery.DOCUMENT_ID);
fullTextQuery.setFirstResult((int)pageable.getOffset());
fullTextQuery.setMaxResults(pageable.getPageSize());
//FullTextQuery will log if org.hibernate.search.fulltext_query is set to DEBUG
projResultList = fullTextQuery.getResultList();
//getResultSize must go after getResultList or query will be executed twice
resultSize = fullTextQuery.getResultSize();;
Iterator projIter = projResultList.iterator();
int docId;
float score;
PatentDocDO doc;
while (projIter.hasNext()) {
projResult = (Object[]) projIter.next();
docRes = new PatentDocSearchResultDO();
score = (float) projEntry[0];
doc = (PatentDocDO) projEntry[1];
docId=(int) projResult[2];
docRes.setDoc(doc);
docRes.setRelevanceScore(score);
docRes.setDocId(docId);
results.add(docRes);
}
Note that everything is done in a single query. As my search queries are quite complex, that is important from a performance perspective. In digging through the documentation of HS 6, I cannot find the equivalent of this in the query/projection DSL. I see the projection section which just returns the scores, but that requires a second search. Am I missing something? Is there a way in HS 6 to do this in a single query? BTW... I am using the Lucene backend.
Thanks,
Keith
PS> Yes, my users are advanced patent searchers and understand the concepts and challenges around scoring
question from:
https://stackoverflow.com/questions/65895008/doc-score-retrieval-in-hibernate-search-6 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…