is it possible to use a match query which searches in "_all" and combine it
with boosting at query time?
For example: I have a field title and body. Now I'm searching for { "match"
: { "_all" : "foo" } }, but I want to boost hits in title over body at
query time (not at index time).
Why not use the multi_match query? This allows you to use multiple
fields at same time with different boosts.
Example:
{
"multi_match" : {
"query" : "foo",
"fields" : ["title^1.5", "body^0.5"]
}
}
Since you don't use index time boosts and you want have different
weight per field this seems a better approach to me. You can then also
disable the _all field in your mapping, which will save you disk space
too!
is it possible to use a match query which searches in "_all" and combine it
with boosting at query time?
For example: I have a field title and body. Now I'm searching for { "match"
: { "_all" : "foo" } }, but I want to boost hits in title over body at query
time (not at index time).
On Thursday, October 18, 2012 3:27:25 PM UTC+2, Martijn v Groningen wrote:
Why not use the multi_match query? This allows you to use multiple
fields at same time with different boosts.
Example:
{
"multi_match" : {
"query" : "foo",
"fields" : ["title^1.5", "body^0.5"]
}
}
Thank you for your reply. I also thought about using a specific list of
fields. But this was only a simplified example. In reality i have several
fields which are not necessary known to me during query time. Thats why I
want to use the "_all" field, but still boost specific fields. E.g. search
for "foo" in "_all" fields, but boost hits, where it is found in the
attribute "title".
So you don't know what fields might by used during query time, but do
you know what fields you possibly want to boost?
If that is the case then I think you still use the match_all query.
Just include the _all field.
{
"multi_match" : {
"query" : "foo",
"fields" : ["_all", "title^2"]
}
}
If a document has a match on either _all field or title field it will
be returned (like a OR). Documents with a hit in title will get an
extra boost of 2.
On Thursday, October 18, 2012 3:27:25 PM UTC+2, Martijn v Groningen wrote:
Why not use the multi_match query? This allows you to use multiple
fields at same time with different boosts.
Example:
{
"multi_match" : {
"query" : "foo",
"fields" : ["title^1.5", "body^0.5"]
}
}
Thank you for your reply. I also thought about using a specific list of
fields. But this was only a simplified example. In reality i have several
fields which are not necessary known to me during query time. Thats why I
want to use the "_all" field, but still boost specific fields. E.g. search
for "foo" in "_all" fields, but boost hits, where it is found in the
attribute "title".
On Thursday, October 18, 2012 4:47:58 PM UTC+2, Martijn v Groningen wrote:
So you don't know what fields might by used during query time, but do
you know what fields you possibly want to boost?
If that is the case then I think you still use the match_all query.
Just include the _all field.
{
"multi_match" : {
"query" : "foo",
"fields" : ["_all", "title^2"]
}
}
If a document has a match on either _all field or title field it will
be returned (like a OR). Documents with a hit in title will get an
extra boost of 2.
Martijn
Great. This is what I was looking for. Especially the the link to dis_max
in the documentation about multi_match gave me a good clue.
One further question regarding negative boosting: Let's say I want to down
boost hits, where it matches in the title. As far as I can see both with
bool and with dis_max this is not possible, because it either will take the
sum (bool) or the maximum (dis_max).
On Thursday, October 18, 2012 4:47:58 PM UTC+2, Martijn v Groningen wrote:
So you don't know what fields might by used during query time, but do
you know what fields you possibly want to boost?
If that is the case then I think you still use the match_all query.
Just include the _all field.
{
"multi_match" : {
"query" : "foo",
"fields" : ["_all", "title^2"]
}
}
If a document has a match on either _all field or title field it will
be returned (like a OR). Documents with a hit in title will get an
extra boost of 2.
Martijn
Great. This is what I was looking for. Especially the the link to dis_max in
the documentation about multi_match gave me a good clue.
One further question regarding negative boosting: Let's say I want to down
boost hits, where it matches in the title. As far as I can see both with
bool and with dis_max this is not possible, because it either will take the
sum (bool) or the maximum (dis_max).
As far as I can see, the boosting-query only allows to boost up or down, but not different boosts for different fields. E.G. having field x, y, z, where x should be boosted with 2.0, y with boost 3.0 and z with boost 4.0. Am I right?
As far as I can see, the boosting-query only allows to boost up or
down, but not different boosts for different fields. E.G. having field
x, y, z, where x should be boosted with 2.0, y with boost 3.0 and z
with boost 4.0. Am I right?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.