Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
582 views
in Technique[技术] by (71.8m points)

lucene - Doc Score Retrieval In Hibernate Search 6

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...