Boosting a document value

Hi,

I know something like this was already answered but it's not what I need :slight_smile:

I have two documents that look like this:

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "10"
},
{
"value" : "red",
"my_boost" : "2"
}
]
}
}

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "2"
},
{
"value" : "red",
"my_boost" : "10"
}
]
}

If I search for "red" I will get these two documents.

BUT :slight_smile:

I would like the query to use the my_boost field to push the score higher
for the relevant search

This means that I want the second document to be first (because it has a
my_boost=10).

I was thinking that custom_score & script might help me - but I don't know
how to accomplish it.

Any help will be appreciated.

Noam.

--
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 need to show us your mapping for the fields and also your query.

To my knowledge, the only way to use _boost values on specific keywords is
via the _all field. (I'm not 100% sure but I've tried to make this work for
a long time and the only success I've had is querying _all field.)

Elasticsearch Platform โ€” Find real-time answers at scale | Elastic. By
default, all properties are copied over to the _all field.

Next you must query on your _all field. The easiest way to do that is to
omit any field scoping from the query; this will default search the _all
field:

curl -XGET
'localhost:9200/index/_search?&search_type=dfs_query_then_fetch&pretty=true'
-d '{
"query": {
"query_string": {
"query": "red"
}
},
"sort": [{"_score": "desc"}],
"explain": true
}'

Notice I'm using dfs_query_then_fetch Elasticsearch Platform โ€” Find real-time answers at scale | Elastic.
This will give you more accurate scoring that you will need.

There are other issues you will need to consider like if "red" is indexed
anywhere else in the document, it means it will affect the term-frequencies
and your ranking will be affected.

To receive better help, please post a complete curl
recreation: Elasticsearch Platform โ€” Find real-time answers at scale | Elastic

On Monday, February 18, 2013 3:04:09 AM UTC-8, Noam Guy wrote:

Hi,

I know something like this was already answered but it's not what I need
:slight_smile:

I have two documents that look like this:

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "10"
},
{
"value" : "red",
"my_boost" : "2"
}
]
}
}

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "2"
},
{
"value" : "red",
"my_boost" : "10"
}
]
}

If I search for "red" I will get these two documents.

BUT :slight_smile:

I would like the query to use the my_boost field to push the score higher
for the relevant search

This means that I want the second document to be first (because it has a
my_boost=10).

I was thinking that custom_score & script might help me - but I don't know
how to accomplish it.

Any help will be appreciated.

Noam.

--
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.

We have the similar problem.

Here is our scenario:

We have a magazine DB. each magazine has a list of category tags, each tag
has weight. Number of tags for each magazine is NOT fixed. The magazine doc
also has name and attachment fileds.

When searching a keyword "sports",

if the keyword occurs in name filed, the document get boosted - we can use
boost value for name field.
if the keyword occurs in attachment, no extra boost.
if the keyword occurs in the tags, the document get boosted - we want to
use the tag weight to boost the doc.

One possible solution I can imagine is using script and custom score and
sort by cscore. However, as a newbie, I could not figure it out.

Appreciate for any help.

Allen

On Monday, February 18, 2013 6:04:09 AM UTC-5, Noam Guy wrote:

Hi,

I know something like this was already answered but it's not what I need
:slight_smile:

I have two documents that look like this:

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "10"
},
{
"value" : "red",
"my_boost" : "2"
}
]
}
}

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "2"
},
{
"value" : "red",
"my_boost" : "10"
}
]
}

If I search for "red" I will get these two documents.

BUT :slight_smile:

I would like the query to use the my_boost field to push the score higher
for the relevant search

This means that I want the second document to be first (because it has a
my_boost=10).

I was thinking that custom_score & script might help me - but I don't know
how to accomplish it.

Any help will be appreciated.

Noam.

--
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.

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not use
the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

AtoZ - I feel that there is solution :slight_smile:

Let's wait :slight_smile:

Noam

--
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.

Noam, only _boost, and boost are valid boost attribute keys. You cannot use
an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference: Elasticsearch Platform โ€” Find real-time answers at scale | Elastic
(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not use
the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

The _boost field is only for index-time boosts. Noam is looking for
something like a "dynamic" boost, where the value used changes depending
the the result.

IIRC, custom scorers do not work with nested fields, only parent fields.
You might want to try a nested queries.

--

Ivan

On Tue, Feb 19, 2013 at 10:41 AM, Jade Dominguez superjadex12@gmail.comwrote:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference:
Elasticsearch Platform โ€” Find real-time answers at scale | Elastic(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

Hi Ivan,

You are right - I need a "dynamic" boost... (Jade - thank you any how..).
Regarding the nested queries - can you give me an example (that uses a
"dynamic" boost value) which I can learn from?

Thank you all :slight_smile:

On Tuesday, February 19, 2013 8:50:36 PM UTC+2, Ivan Brusic wrote:

The _boost field is only for index-time boosts. Noam is looking for
something like a "dynamic" boost, where the value used changes depending
the the result.

IIRC, custom scorers do not work with nested fields, only parent fields.
You might want to try a nested queries.

--

Ivan

On Tue, Feb 19, 2013 at 10:41 AM, Jade Dominguez <superj...@gmail.com<javascript:>

wrote:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference:
Elasticsearch Platform โ€” Find real-time answers at scale | Elastic(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {

    "properties" : {
        "lists" : {

            "properties" : {

                "value" : {"type" : "string"}, 

                "my_boost" : {"type" : "string"}

            }
        }

    }
}

}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.

Hi Jade,

Thank you so much for your answer. I think I almost catch what I want

One more question: how multiple keyword boost value in a list impacts the
document?

In my case, we will have a tag LIST. And some tags may contain same
term/keyword:

Document 1:
tag1: "sports", _boost: 2,
tag2: "winter sports", _boost: 1.4,
tag3: "tech": _boost: 1.1,
Content: "blah, blah, sports, blah, blan", _boost: 1.0

Document 2:
tag1: "sports", _boost: 2,
tag2: "blah music", _boost: 1.5,
tag3: "ent", _boost: 1.3
Content: "blah, blah, music, blah, blah", _boost: 1.0

When I search keyword "sports" and sort it by _score, I assume, document 1
will be returned before document 2. How the _score gets computed exactly?

Thanks a lot,

Allen

On Tuesday, February 19, 2013 1:41:12 PM UTC-5, Jade Dominguez wrote:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference:
Elasticsearch Platform โ€” Find real-time answers at scale | Elastic(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

Hi Jade!

Your example (Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub) is close to what
I'm trying to do, but when I run it i get an error:

$ curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
{"error":"UnsupportedOperationException[You cannot set an index-time boost:
norms are omitted for field 'skills']","status":500}

Am I missing something?

Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade Dominguez:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference:
Elasticsearch Platform โ€” Find real-time answers at scale | Elastic(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact same number of skills (1) that term-frequencies are not an issue. ยท GitHub

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

did you change the field mappings? index time boosts are stored in the
norms so you cannot set omit_norms: false
On Feb 20, 2013 8:18 AM, "markusos" markus.ostberg@gmail.com wrote:

Hi Jade!

Your example (https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626) is
close to what I'm trying to do, but when I run it i get an error:

$ curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
{"error":"UnsupportedOperationException[You cannot set an index-time
boost: norms are omitted for field 'skills']","status":500}

Am I missing something?

Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade
Dominguez:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference: http://www.Elasticsearch Platform โ€” Find real-time answers at scale | Elastic
reference/mapping/core-types.**htmlhttp://www.elasticsearch.org/guide/reference/mapping/core-types.html(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {
"properties" : {
"lists" : {
"properties" : {
"value" : {"type" : "string"},
"my_boost" : {"type" : "string"}
}
}
}
}
}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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.

I just copy the script and paste it in the terminal, have not changed
anything in it. I get the error on all curl -XPOST localhost:9200/p/profile
-d '{

"skills": [ { "_value": "ruby", "_boost": 5 } ]

}' where _boost != 1. I'm using the latest stable release (0.20.5 -
2013-02-14).

Den onsdagen den 20:e februari 2013 kl. 18:33:47 UTC+1 skrev Jade Dominguez:

did you change the field mappings? index time boosts are stored in the
norms so you cannot set omit_norms: false
On Feb 20, 2013 8:18 AM, "markusos" <markus....@gmail.com <javascript:>>
wrote:

Hi Jade!

Your example (https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626) is
close to what I'm trying to do, but when I run it i get an error:

$ curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
{"error":"UnsupportedOperationException[You cannot set an index-time
boost: norms are omitted for field 'skills']","status":500}

Am I missing something?

Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade
Dominguez:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference: http://www.Elasticsearch Platform โ€” Find real-time answers at scale | Elastic
reference/mapping/core-types.**htmlhttp://www.elasticsearch.org/guide/reference/mapping/core-types.html(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {

    "properties" : {
        "lists" : {

            "properties" : {

                "value" : {"type" : "string"}, 

                "my_boost" : {"type" : "string"}

            }
        }

    }
}

}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.

Tested now in an older version of Elasticsearch (0.19.0 - 2012-03-01) and
the example works there. Is there some reason why this doesn't work in the
newer releases?

Den onsdagen den 20:e februari 2013 kl. 20:45:50 UTC+1 skrev markusos:

I just copy the script and paste it in the terminal, have not changed
anything in it. I get the error on all curl -XPOST
localhost:9200/p/profile -d '{

"skills": [ { "_value": "ruby", "_boost": 5 } ]

}' where _boost != 1. I'm using the latest stable release (0.20.5 -
2013-02-14).

Den onsdagen den 20:e februari 2013 kl. 18:33:47 UTC+1 skrev Jade
Dominguez:

did you change the field mappings? index time boosts are stored in the
norms so you cannot set omit_norms: false
On Feb 20, 2013 8:18 AM, "markusos" markus....@gmail.com wrote:

Hi Jade!

Your example (https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626) is
close to what I'm trying to do, but when I run it i get an error:

$ curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
{"error":"UnsupportedOperationException[You cannot set an index-time
boost: norms are omitted for field 'skills']","status":500}

Am I missing something?

Den tisdagen den 19:e februari 2013 kl. 19:41:12 UTC+1 skrev Jade
Dominguez:

Noam, only _boost, and boost are valid boost attribute keys. You cannot
use an arbitrarily named value for boosting. The mapping you've shown is
actually mapping an object with properties "value" and "my_boost". You want
to be mapping a string type with the value of "value" and the internal
boost of _boost:

{
"message" : {
"_value": "boosted value",
"_boost": 2.0
}
}

Reference: http://www.Elasticsearch Platform โ€” Find real-time answers at scale | Elastic
reference/mapping/core-types.**htmlhttp://www.elasticsearch.org/guide/reference/mapping/core-types.html(under type String)

I have made a control-test example to highlight boosting by individual
keyword value: https://gist.github.**com/plusjade/4988626https://gist.github.com/plusjade/4988626

Please verify you can run this and get back the expected results. Any
further questions should build off this control test so that we are in
complete alignment.

On Monday, February 18, 2013 11:20:59 PM UTC-8, Noam Guy wrote:

Hi Jade,

First of all thanks for the reply.

This is how the mapping should look like:

{
"image" : {

    "properties" : {
        "lists" : {

            "properties" : {

                "value" : {"type" : "string"}, 

                "my_boost" : {"type" : "string"}

            }
        }

    }
}

}

The problem (as I can see :slight_smile: ) from your solution is that it does not
use the dynamic boost (my_boost) I store when indexing the document.

Am I missing something?

Noam.

--
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 elasticsearc...@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.

Hi Noam

I know something like this was already answered but it's not what I
need :slight_smile:

I have two documents that look like this:

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "10"
},
{
"value" : "red",
"my_boost" : "2"
}
]
}
}

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "2"
},
{
"value" : "red",
"my_boost" : "10"
}
]
}

If I search for "red" I will get these two documents.

BUT :slight_smile:

I would like the query to use the my_boost field to push the score
higher for the relevant search

This means that I want the second document to be first (because it has
a my_boost=10).

I was thinking that custom_score & script might help me - but I don't
know how to accomplish it.

A custom_score script is the way to go, but the other complication is
that you are using an array of objects. In order to consider the
properties in each object independently, you need to change lists to be
of type "nested".

I have written a complete example showing how to achieve what you want
on stackoverflow:

clint

--
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.

Great I will take a look at it as soon as the kids go to sleep :slight_smile:
On Feb 21, 2013 4:51 PM, "Clinton Gormley" clint@traveljury.com wrote:

Hi Noam

I know something like this was already answered but it's not what I
need :slight_smile:

I have two documents that look like this:

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "10"
},
{
"value" : "red",
"my_boost" : "2"
}
]
}
}

{
"image" : {
"lists" : [
{
"value" : "dior",
"my_boost" : "2"
},
{
"value" : "red",
"my_boost" : "10"
}
]
}

If I search for "red" I will get these two documents.

BUT :slight_smile:

I would like the query to use the my_boost field to push the score
higher for the relevant search

This means that I want the second document to be first (because it has
a my_boost=10).

I was thinking that custom_score & script might help me - but I don't
know how to accomplish it.

A custom_score script is the way to go, but the other complication is
that you are using an array of objects. In order to consider the
properties in each object independently, you need to change lists to be
of type "nested".

I have written a complete example showing how to achieve what you want
on stackoverflow:

java - ElasticSearch : Sorting by nested documents' values - Stack Overflow

clint

--
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.