# Is there an opposite of dismaxquery? E.g. take the minimum score of two queries?

**URL:** <https://discuss.elastic.co/t/is-there-an-opposite-of-dismaxquery-e-g-take-the-minimum-score-of-two-queries/19509>\
**Category:** Elasticsearch\
**Created:** [August 28, 2014, 9:26am UTC](https://discuss.elastic.co/t/is-there-an-opposite-of-dismaxquery-e-g-take-the-minimum-score-of-two-queries/19509 "2014-08-28T09:26:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Bronnimann](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@Lucas\_Bronnimann](https://discuss.elastic.co/u/Lucas_Bronnimann)\
**Post date:** [August 28, 2014, 9:26am UTC](https://discuss.elastic.co/t/is-there-an-opposite-of-dismaxquery-e-g-take-the-minimum-score-of-two-queries/19509/1 "2014-08-28T09:26:23Z")

</div>

Hi all

Basically I have two queries that I would like to combine in a somewhat  
unusual way.

Lets say query A is _"Albino Melanism"_ and query B is\* "Elephant Tiger"\*.  
I have lots of search results which have either one or the other, but I am  
mostly interested in those where both queries return at least some score.  
Any text only containing all the words of query A or query B should be  
scored lower than a query containing some of query A and query B. (e.g. the  
document with the text "Albino Melanism ..." is worth nothing if there is  
no mention of an elephant or tiger, I'd rather have the text "Albino  
Elephant ..." with no mentions of tigers / melanism)

A dismax query does pretty much the opposite of what I want to do: It takes  
two subqueries and returns the maximum. However I actually want the minimum  
of those subqueries.

Is there a way to do this with elasticsearch?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 28, 2014, 5:15pm UTC](https://discuss.elastic.co/t/is-there-an-opposite-of-dismaxquery-e-g-take-the-minimum-score-of-two-queries/19509/2 "2014-08-28T17:15:33Z")

</div>

A dismax query will basically rewrite the query as a boolean query. Can you  
create your own query where one of the clauses has a negative boost? Still  
tricky since you basically need the inverse of cross/best\_field where the  
field remains the same, but the query changes.

--  
Ivan

On Thu, Aug 28, 2014 at 2:26 AM, Lucas Brönnimann [acriaos@gmail.com](mailto:acriaos@gmail.com) wrote:

> Hi all
> 
> Basically I have two queries that I would like to combine in a somewhat  
> unusual way.
> 
> Lets say query A is _"Albino Melanism"_ and query B is\* "Elephant Tiger"\*.  
> I have lots of search results which have either one or the other, but I am  
> mostly interested in those where both queries return at least some score.  
> Any text only containing all the words of query A or query B should be  
> scored lower than a query containing some of query A and query B. (e.g. the  
> document with the text "Albino Melanism ..." is worth nothing if there is  
> no mention of an elephant or tiger, I'd rather have the text "Albino  
> Elephant ..." with no mentions of tigers / melanism)
> 
> A dismax query does pretty much the opposite of what I want to do: It  
> takes two subqueries and returns the maximum. However I actually want the  
> minimum of those subqueries.
> 
> Is there a way to do this with elasticsearch?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/273ed06f-3eda-4e67-85b7-ea7bca83ebea%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAsk7c%2BFwgXqg-tzC1VEfrKK5q%2BAYXbu2KN\_3Hnjf0qMg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAsk7c%2BFwgXqg-tzC1VEfrKK5q%2BAYXbu2KN_3Hnjf0qMg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:05am UTC](https://discuss.elastic.co/t/is-there-an-opposite-of-dismaxquery-e-g-take-the-minimum-score-of-two-queries/19509/3 "2017-07-06T01:05:45Z")

</div>


