OR query

I have an index with "name" and "description" filed. I am running a Boolean
query against my index. Sometimes the term is present in both name and
description fields, in this case the documents in which both the name and
description contains the search term are scored higher compared to the ones
having either the name or the description having the search term. What I
want is to score them equal. So the the documents with either name or
description having the term has the same score as the document having the
search term present in both name and description. Is it possible? Here is
the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to have
the same score. As all documents contains the term "xyz" either in name or
in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Getting the score to be exactly the same will be difficult. First of all,
if your description field is variable between documents, then the field
norm will have a different value.

A few things to try out. Omit term frequencies and norms for all the fields
used in the query. Then set disableCoord on the bool query to true so that
one clause is not score higher than the other.

--
Ivan

On Tue, May 14, 2013 at 10:35 AM, Amit Patel avpatel.257@gmail.com wrote:

I have an index with "name" and "description" filed. I am running a
Boolean query against my index. Sometimes the term is present in both name
and description fields, in this case the documents in which both the name
and description contains the search term are scored higher compared to the
ones having either the name or the description having the search term. What
I want is to score them equal. So the the documents with either name or
description having the term has the same score as the document having the
search term present in both name and description. Is it possible? Here is
the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to have
the same score. As all documents contains the term "xyz" either in name or
in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Just a thought: I'm wondering if using custom scoring can help you here: http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 15 mai 2013 à 08:17, Ivan Brusic ivan@brusic.com a écrit :

Getting the score to be exactly the same will be difficult. First of all, if your description field is variable between documents, then the field norm will have a different value.

A few things to try out. Omit term frequencies and norms for all the fields used in the query. Then set disableCoord on the bool query to true so that one clause is not score higher than the other.

--
Ivan

On Tue, May 14, 2013 at 10:35 AM, Amit Patel avpatel.257@gmail.com wrote:
I have an index with "name" and "description" filed. I am running a Boolean query against my index. Sometimes the term is present in both name and description fields, in this case the documents in which both the name and description contains the search term are scored higher compared to the ones having either the name or the description having the search term. What I want is to score them equal. So the the documents with either name or description having the term has the same score as the document having the search term present in both name and description. Is it possible? Here is the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to have the same score. As all documents contains the term "xyz" either in name or in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

It sounds like what you want is to use the dis_max query instead of the
bool query

http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query/

Bool sums the score for each matching clause, while dis_max uses the score
from the best matching clause

clint

On 15 May 2013 09:44, David Pilato david@pilato.fr wrote:

Just a thought: I'm wondering if using custom scoring can help you here:
http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 15 mai 2013 à 08:17, Ivan Brusic ivan@brusic.com a écrit :

Getting the score to be exactly the same will be difficult. First of all,
if your description field is variable between documents, then the field
norm will have a different value.

A few things to try out. Omit term frequencies and norms for all the
fields used in the query. Then set disableCoord on the bool query to true
so that one clause is not score higher than the other.

--
Ivan

On Tue, May 14, 2013 at 10:35 AM, Amit Patel avpatel.257@gmail.comwrote:

I have an index with "name" and "description" filed. I am running a
Boolean query against my index. Sometimes the term is present in both name
and description fields, in this case the documents in which both the name
and description contains the search term are scored higher compared to the
ones having either the name or the description having the search term. What
I want is to score them equal. So the the documents with either name or
description having the term has the same score as the document having the
search term present in both name and description. Is it possible? Here is
the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to
have the same score. As all documents contains the term "xyz" either in
name or in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks guys. I will try the suggestions and post back the results.

On Wed, May 15, 2013 at 6:32 AM, Clinton Gormley clint@traveljury.comwrote:

It sounds like what you want is to use the dis_max query instead of the
bool query

http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query/

Bool sums the score for each matching clause, while dis_max uses the score
from the best matching clause

clint

On 15 May 2013 09:44, David Pilato david@pilato.fr wrote:

Just a thought: I'm wondering if using custom scoring can help you here:
http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 15 mai 2013 à 08:17, Ivan Brusic ivan@brusic.com a écrit :

Getting the score to be exactly the same will be difficult. First of all,
if your description field is variable between documents, then the field
norm will have a different value.

A few things to try out. Omit term frequencies and norms for all the
fields used in the query. Then set disableCoord on the bool query to true
so that one clause is not score higher than the other.

--
Ivan

On Tue, May 14, 2013 at 10:35 AM, Amit Patel avpatel.257@gmail.comwrote:

I have an index with "name" and "description" filed. I am running a
Boolean query against my index. Sometimes the term is present in both name
and description fields, in this case the documents in which both the name
and description contains the search term are scored higher compared to the
ones having either the name or the description having the search term. What
I want is to score them equal. So the the documents with either name or
description having the term has the same score as the document having the
search term present in both name and description. Is it possible? Here is
the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to
have the same score. As all documents contains the term "xyz" either in
name or in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/BvOCc8COVGw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Looks like the dis-max-query is the way to go in this case. Thanks for your
help.

On Wed, May 15, 2013 at 6:07 PM, Amit Patel avpatel.257@gmail.com wrote:

Thanks guys. I will try the suggestions and post back the results.

On Wed, May 15, 2013 at 6:32 AM, Clinton Gormley clint@traveljury.comwrote:

It sounds like what you want is to use the dis_max query instead of the
bool query

http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query/

Bool sums the score for each matching clause, while dis_max uses the
score from the best matching clause

clint

On 15 May 2013 09:44, David Pilato david@pilato.fr wrote:

Just a thought: I'm wondering if using custom scoring can help you here:
http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 15 mai 2013 à 08:17, Ivan Brusic ivan@brusic.com a écrit :

Getting the score to be exactly the same will be difficult. First of
all, if your description field is variable between documents, then the
field norm will have a different value.

A few things to try out. Omit term frequencies and norms for all the
fields used in the query. Then set disableCoord on the bool query to true
so that one clause is not score higher than the other.

--
Ivan

On Tue, May 14, 2013 at 10:35 AM, Amit Patel avpatel.257@gmail.comwrote:

I have an index with "name" and "description" filed. I am running a
Boolean query against my index. Sometimes the term is present in both name
and description fields, in this case the documents in which both the name
and description contains the search term are scored higher compared to the
ones having either the name or the description having the search term. What
I want is to score them equal. So the the documents with either name or
description having the term has the same score as the document having the
search term present in both name and description. Is it possible? Here is
the example:

{
"name": "xyz",
"description": "abc xyz"
},
{
"name": "abc",
"description": "xyz pqr"
},
{
"name": "xyz",
"description": "abc pqr"
}

If the user search for term "xyz" I want all three documents above to
have the same score. As all documents contains the term "xyz" either in
name or in description or in both fields.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/BvOCc8COVGw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.