Skip to content

Conversation

@jrodewig
Copy link
Contributor

Rewrites the dis_max query to use the new query format.

This is part of #40977, an effort to standardize documentation for query types.

Before

Before image Before Image

After

After image After Image

@jrodewig jrodewig added :Search/Search Search-related issues that do not fall into other categories >docs General docs changes v7.0.2 v7.1.2 v7.2.1 v7.3.0 v8.0.0 labels Jun 25, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

@jrodewig Thanks! This is indeed a nice restructuring. But we lost the use case for this query. Do we plan to put the use case somewhere else in the documentation?

clauses.

If a returned document matches multiple query clauses, the `dis_max` query
assigns the document the highest relevance score from any matching clause.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is important to add here "plus a tie breaking increment for any additional matching subqueries".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-added with 6fa3e0c.

If a document matches multiple clauses, the `dis_max` query calculates the
relevance score for the document as follows:

. Take the highest relevance score from a matching clause.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a little bit more clear: "take the score from a matching clause with the highest relevance score"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added with 6fa3e0c.


. Take the highest relevance score from a matching clause.
. Multiply the score from any other matching clauses by the `tie_breaker` value.
. Add the highest score to the multiplied scores and normalize.
Copy link
Contributor

Choose a reason for hiding this comment

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

what is normalize here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this with 6fa3e0c.

@jrodewig
Copy link
Contributor Author

jrodewig commented Jul 2, 2019

Thanks for the review @mayya-sharipova! I may have gotten carried away with edits so I re-added some context for the use case and example with 6fa3e0c.

factors. If the query is "albino elephant," this ensures that "albino" matching
one field and "elephant" matching another gets a higher score than "albino"
matching both fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jrodewig Thanks for quickly addressing the feedback.
One small comment, the way information is presented now looks like the query in the example will address what you described before it: " If the query is "albino elephant" this ensures that "albino" matching one field and "elephant" matching another gets a higher score than "albino" matching both fields.". But for this, we need a slightly different query: bool with two should dismax clauses for each field.

May be better, would be to remove this sentence about "albino elephant" all together? WDYT?

Copy link
Contributor Author

@jrodewig jrodewig Jul 2, 2019

Choose a reason for hiding this comment

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

@mayya-sharipova Thanks again for your kind review!

I think you're right about removing the sentence. I also updated the example request to fit the use case without introducing a more complex bool query.

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

@jrodewig Thanks for your patience on this.

@jrodewig
Copy link
Contributor Author

jrodewig commented Jul 3, 2019

@elasticmachine run elasticsearch-ci/oss-distro-docs

@jrodewig jrodewig merged commit 0753b41 into elastic:master Jul 3, 2019
@jrodewig jrodewig deleted the rewrite-dis-max-query branch July 3, 2019 12:55
jrodewig added a commit that referenced this pull request Jul 3, 2019
jrodewig added a commit that referenced this pull request Jul 3, 2019
jrodewig added a commit that referenced this pull request Jul 3, 2019
jrodewig added a commit that referenced this pull request Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>docs General docs changes :Search/Search Search-related issues that do not fall into other categories v7.0.2 v7.1.2 v7.2.1 v7.3.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants