About scripting elasticsearch with plugin lang-javascript


(gkcr2d2) #1

Hello,

I try to query with custom score (with param lang => js)
But, I didn't find documentation about the way to realise the script (acced
to the _source values, modify score etc.)

The score value that i need to personalize depends on the value of one
field :
if (myfield == '1234') {
score += 10;
} else if (myfield == '456' )
{
score += 20;
}

Thank you for your help.

Best regards,


(Igor Motov) #2

It's the same as with mvel. You can find details
in http://www.elasticsearch.org/guide/reference/modules/scripting.html

if (_source['myfield'] == '1234') {
_score + 10;
} else if (_source['myfield'] == '456') {
_score + 20;
} else {
_score;
}

On Thursday, June 21, 2012 10:49:03 AM UTC-4, gkcr2d2 wrote:

Hello,

I try to query with custom score (with param lang => js)
But, I didn't find documentation about the way to realise the script
(acced to the _source values, modify score etc.)

The score value that i need to personalize depends on the value of one
field :
if (myfield == '1234') {
score += 10;
} else if (myfield == '456' )
{
score += 20;
}

Thank you for your help.

Best regards,


(gkcr2d2) #3

Thank you !

Le vendredi 22 juin 2012 22:28:06 UTC+2, Igor Motov a écrit :

It's the same as with mvel. You can find details in
http://www.elasticsearch.org/guide/reference/modules/scripting.html

if (_source['myfield'] == '1234') {
_score + 10;
} else if (_source['myfield'] == '456') {
_score + 20;
} else {
_score;
}

On Thursday, June 21, 2012 10:49:03 AM UTC-4, gkcr2d2 wrote:

Hello,

I try to query with custom score (with param lang => js)
But, I didn't find documentation about the way to realise the script
(acced to the _source values, modify score etc.)

The score value that i need to personalize depends on the value of one
field :
if (myfield == '1234') {
score += 10;
} else if (myfield == '456' )
{
score += 20;
}

Thank you for your help.

Best regards,


(system) #4