# HS6 SearchResult.took() duration incorrect

**URL:** <https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137>\
**Category:** Hibernate Search\
**Created:** [March 4, 2021, 6:26pm UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137 "2021-03-04T18:26:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmelkild](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kmelkild](https://discourse.hibernate.org/u/kmelkild)\
**Post date:** [March 4, 2021, 6:26pm UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/1 "2021-03-04T18:26:12Z")

</div>

Please check out the code below to see if I am using this incorrectly, but it looks like the duration being returned by .took() is incorrect. Thanks, Keith

```
     LuceneSearchQuery<PatentDocSearchResultDO> query = 
      Search.session(entityManager)
        .search(PatentDocDO.class).extension(LuceneExtension.get())
        .select(f -> f.composite(PatentDocSearchResultDO::new, f.score(), f.entity()))
        .where(f -> f.bool((b -> {
           addSearchClausesFromCriteria(f, b,criteria);
        })))
             .toQuery();
        
     logger.info("Fetch start");
       SearchResult<PatentDocSearchResultDO> docSearchResult = query.fetch((int)pageable.getOffset(), pageable.getPageSize());

     logger.info("Fetch complete. Took: {}", docSearchResult.took());

```

Logs:

PatentDocRepositoryImpl INFO 2021-03-04 12:19:16,840 [https-jsse-nio-8443-exec-5]  
com.propat.pas.db.core.PatentDocRepositoryImpl  
Fetch start

query TRACE 2021-03-04 12:19:17,095 [https-jsse-nio-8443-exec-5]  
org.hibernate.search.query  
HSEARCH000274: Executing Lucene query: +(+((org.apache.lucene.queryparser.surround.query.SimpleTermRewriteQuery(XML.ABST, blockchain, org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0)) org.apache.lucene.queryparser.surround.query.DistanceRewriteQuery(XML.ABST, (block W chain\*), org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0))) (+(org.apache.lucene.queryparser.surround.query.SimpleTermRewriteQuery(XML.ACLM, blockchain, org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0)) org.apache.lucene.queryparser.surround.query.DistanceRewriteQuery(XML.ACLM, (block W chain\*), org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0))))^1.2 (org.apache.lucene.queryparser.surround.query.SimpleTermRewriteQuery(TTL, blockchain, org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0)) org.apache.lucene.queryparser.surround.query.DistanceRewriteQuery(TTL, (block W chain\*), org.apache.lucene.queryparser.surround.query.BasicQueryFactory(maxBasicQueries: 262144, queriesMade: 0)))) #CASE.PDATE:[668066400000 TO 9223372036854775807] #DOC\_TYPE:GRANT #(CASE.TYPE:UTILITY))

PatentDocRepositoryImpl INFO 2021-03-04 12:19:17,788 [https-jsse-nio-8443-exec-5]  
com.propat.pas.db.core.PatentDocRepositoryImpl  
Fetch complete. Took: PT164H44M58.342S

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [March 5, 2021, 7:41am UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/2 "2021-03-05T07:41:17Z")

</div>

Wow, that’s embarassing. There is indeed a bug. Thanks for the report, I’ll have a look ASAP: [[HSEARCH-4183] SearchResult.took() returns incorrect, very large value with the Lucene backend - Hibernate JIRA](https://hibernate.atlassian.net/browse/HSEARCH-4183)

---

<div class="post-metadata">

**Author:** ![kmelkild](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kmelkild](https://discourse.hibernate.org/u/kmelkild)\
**Post date:** [March 5, 2021, 2:33pm UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/3 "2021-03-05T14:33:04Z")

</div>

I see from the JIRA ticket you already have a fix in. Thanks for the fast response! BTW, when this is delivered, will took return the duration of the query not including the hibernate object load time? That is what I am most interested in.

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [March 5, 2021, 2:45pm UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/4 "2021-03-05T14:45:52Z")

</div>

Yes, the returned value includes only the time spent executing the query. Entity loading is ignored.

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [April 14, 2021, 7:03am UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/5 "2021-04-14T07:03:26Z")

</div>

@kmelkild The fix is available in the recently released [6.0.3.Final](https://in.relation.to/2021/04/14/hibernate-search-6-0-3-Final/). Sorry it took so long… 🙂

---

<div class="post-metadata">

**Author:** ![kmelkild](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kmelkild](https://discourse.hibernate.org/u/kmelkild)\
**Post date:** [April 14, 2021, 1:20pm UTC](https://discourse.hibernate.org/t/hs6-searchresult-took-duration-incorrect/5137/6 "2021-04-14T13:20:42Z")

</div>

No problem. It’s funny, I was just about to ping you all on an ETA for 6.0.3 and then I saw it show up yesterday. Thanks again.
