Boosting fields based on type in multi-index searches


(seallison) #1

I have two indices each storing a specific type "Products" and "Stores."
Some of the attribute names of each type overlap. For instance, both
Products and Stores have a "name" attribute. How can I search across both
indices while giving different boost values to the same attribute? I want
to give Products.name a boost of 1.3 and Stores.name a boost of 1.7. I
don't see a way to do this with the query string query.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/914d2bd2-84ec-4acc-9064-a66b9f94647d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

If I understand you correctly, let's say you have one or more indexes. Then
you have 2 types named "product" and "store". "product" and "store" both
have the field "name", but you want to boost the product "name" independent
from the store "name". You should be able to do something like this:

{
"query": {
"query_string": {
"query": "blah",
"fields": [
"product.name^1.3",
"store.name^1.7"
]
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0fd7db3f-c691-4ed2-8251-5897dd93b881%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(seallison) #3

That works perfectly, Thanks! I had no idea you could preface the field
paths with the type for boosting like that.

On Monday, February 24, 2014 7:08:31 PM UTC-5, Binh Ly wrote:

If I understand you correctly, let's say you have one or more indexes.
Then you have 2 types named "product" and "store". "product" and "store"
both have the field "name", but you want to boost the product "name"
independent from the store "name". You should be able to do something like
this:

{
"query": {
"query_string": {
"query": "blah",
"fields": [
"product.name^1.3",
"store.name^1.7"
]
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b5860adf-2f96-430a-9b08-1f7064de29bb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4