Skip to content

Set maxScore for empty TopDocs to Nan rather than 0#32938

Merged
javanna merged 6 commits intoelastic:masterfrom
javanna:fix/empty_top_docs_nan
Aug 22, 2018
Merged

Set maxScore for empty TopDocs to Nan rather than 0#32938
javanna merged 6 commits intoelastic:masterfrom
javanna:fix/empty_top_docs_nan

Conversation

@javanna
Copy link
Copy Markdown
Contributor

@javanna javanna commented Aug 17, 2018

We used to set maxScore to 0 within TopDocs in situations where there is really no score as the size was set to 0 and scores were not even tracked. In such scenarios, Float.Nan is more appropriate, which gets converted to max_score: null on the REST layer. That's also more consistent with lucene which set maxScore to Float.Nan when merging empty TopDocs (see TopDocs#merge).

We used to set `maxScore` to `0` within `TopDocs` in situations where there is really no score as the size was set to `0` and scores were not even tracked. In such scenarios, `Float.Nan` is more appropriate, which gets converted to `max_score: null` on the REST layer. That's also more consistent with lucene which set `maxScore` to `Float.Nan` when merging empty `TopDocs` (see `TopDocs#merge`).
@javanna javanna added >bug :Search/Search Search-related issues that do not fall into other categories v7.0.0 labels Aug 17, 2018
@javanna javanna requested a review from jpountz August 17, 2018 10:49
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search-aggs

assertEquals(0f, searchResponse.getHits().getMaxScore(), 0f);
assertEquals(Float.NaN, searchResponse.getHits().getMaxScore(), 0f);
assertEquals(0, searchResponse.getHits().getHits().length);
assertEquals(1, searchResponse.getSuggest().size());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too happy that all the failures I got came from integration tests and docs tests. I added some assertions to QueryPhaseTests but maybe that is not enough. Suggestions are welcome on where to add tests for this change.

@javanna javanna force-pushed the fix/empty_top_docs_nan branch from c7c637c to 9c19b4b Compare August 17, 2018 15:30
@javanna javanna merged commit 393eec1 into elastic:master Aug 22, 2018
@javanna
Copy link
Copy Markdown
Contributor Author

javanna commented Aug 22, 2018

thanks @jpountz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants