Just pushed: custom_score query

Hi,

custom_score query support just pushed to master. This allows to easily
control the scoring (or completely replace) of a query based on the query
score and other document field values. Much more is explained in the issue:
http://github.com/elasticsearch/elasticsearch/issues/220, but here is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"
}

This was requested by several users, for example, to control the scoring
based on recency of documents.

-shay.banon

Hi,

So one can put any sort of a custom formula in that "script" value,
ha?

Sounds like the equivalent of Solr's function queries? (
http://wiki.apache.org/solr/FunctionQuery )
Or maybe a basic version of function queries?

Thanks,
Otis

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/

On Jun 13, 8:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

custom_score query support just pushed to master. This allows to easily
control the scoring (or completely replace) of a query based on the query
score and other document field values. Much more is explained in the issue:Query DSL: custom score (scripted) query · Issue #220 · elastic/elasticsearch · GitHub, but here is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"

}

This was requested by several users, for example, to control the scoring
based on recency of documents.

-shay.banon

Yes, it similar in spirit to function queries, it is actually modeled after
Lucene custom score query (but not used directly). Why do you say its a
basic version of function queries, is there something you can do with the
other that you can't do with this?

-shay.banon

On Tue, Jun 15, 2010 at 8:17 AM, Otis otis.gospodnetic@gmail.com wrote:

Hi,

So one can put any sort of a custom formula in that "script" value,
ha?

Sounds like the equivalent of Solr's function queries? (
http://wiki.apache.org/solr/FunctionQuery )
Or maybe a basic version of function queries?

Thanks,
Otis

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/

On Jun 13, 8:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

custom_score query support just pushed to master. This allows to
easily
control the scoring (or completely replace) of a query based on the query
score and other document field values. Much more is explained in the
issue:Query DSL: custom score (scripted) query · Issue #220 · elastic/elasticsearch · GitHub, but here
is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"

}

This was requested by several users, for example, to control the
scoring
based on recency of documents.

-shay.banon

Hi,

Yeah, I purposely said "basic" simply because I wasn't sure whether
the new "script" stuff can be used to do all those things listed on
http://wiki.apache.org/solr/FunctionQuery . Can it? It would be
great to list a few examples somewhere, so we can get a better idea.

For example, can the "script" functionality be used for these
(randomly picked from the above Wiki page):

http://wiki.apache.org/solr/FunctionQuery#ord
http://wiki.apache.org/solr/FunctionQuery#sum
http://wiki.apache.org/solr/FunctionQuery#recip
http://wiki.apache.org/solr/FunctionQuery#ms
http://wiki.apache.org/solr/FunctionQuery#geohash_-_Convert_to_geohash
http://wiki.apache.org/solr/FunctionQuery#strdist

Thanks,
Otis

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/

On Jun 15, 3:30 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Yes, it similar in spirit to function queries, it is actually modeled after
Lucene custom score query (but not used directly). Why do you say its a
basic version of function queries, is there something you can do with the
other that you can't do with this?

-shay.banon

On Tue, Jun 15, 2010 at 8:17 AM, Otis otis.gospodne...@gmail.com wrote:

Hi,

So one can put any sort of a custom formula in that "script" value,
ha?

Sounds like the equivalent of Solr's function queries? (
http://wiki.apache.org/solr/FunctionQuery)
Or maybe a basic version of function queries?

Thanks,
Otis

Sematext ::http://sematext.com/:: Solr - Lucene - Nutch
Lucene ecosystem search ::http://search-lucene.com/

On Jun 13, 8:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

custom_score query support just pushed to master. This allows to
easily
control the scoring (or completely replace) of a query based on the query
score and other document field values. Much more is explained in the
issue:Query DSL: custom score (scripted) query · Issue #220 · elastic/elasticsearch · GitHub, but here
is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"

}

This was requested by several users, for example, to control the
scoring
based on recency of documents.

-shay.banon

This is just mvel script running, you can do what you want with it, its
basically code... . So, you can do all of the above and much much more since
you are not bounded by static functions.

-shay.banon

On Wed, Jun 16, 2010 at 7:27 AM, Otis otis.gospodnetic@gmail.com wrote:

Hi,

Yeah, I purposely said "basic" simply because I wasn't sure whether
the new "script" stuff can be used to do all those things listed on
http://wiki.apache.org/solr/FunctionQuery . Can it? It would be
great to list a few examples somewhere, so we can get a better idea.

For example, can the "script" functionality be used for these
(randomly picked from the above Wiki page):

http://wiki.apache.org/solr/FunctionQuery#ord
http://wiki.apache.org/solr/FunctionQuery#sum
http://wiki.apache.org/solr/FunctionQuery#recip
http://wiki.apache.org/solr/FunctionQuery#ms
http://wiki.apache.org/solr/FunctionQuery#geohash_-_Convert_to_geohash
http://wiki.apache.org/solr/FunctionQuery#strdist

Thanks,
Otis

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/

On Jun 15, 3:30 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Yes, it similar in spirit to function queries, it is actually modeled
after
Lucene custom score query (but not used directly). Why do you say its a
basic version of function queries, is there something you can do with the
other that you can't do with this?

-shay.banon

On Tue, Jun 15, 2010 at 8:17 AM, Otis otis.gospodne...@gmail.com
wrote:

Hi,

So one can put any sort of a custom formula in that "script" value,
ha?

Sounds like the equivalent of Solr's function queries? (
http://wiki.apache.org/solr/FunctionQuery)
Or maybe a basic version of function queries?

Thanks,
Otis

Sematext ::http://sematext.com/:: Solr - Lucene - Nutch
Lucene ecosystem search ::http://search-lucene.com/

On Jun 13, 8:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

custom_score query support just pushed to master. This allows to
easily
control the scoring (or completely replace) of a query based on the
query
score and other document field values. Much more is explained in the
issue:Query DSL: custom score (scripted) query · Issue #220 · elastic/elasticsearch · GitHub, but
here
is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"

}

This was requested by several users, for example, to control the
scoring
based on recency of documents.

-shay.banon

Oooooh, I see. Never heard of mvel, but it's a mvelous discovery.
Very nice and handy.

Otis

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/

On Jun 16, 4:26 am, Shay Banon shay.ba...@elasticsearch.com wrote:

This is just mvel script running, you can do what you want with it, its
basically code... . So, you can do all of the above and much much more since
you are not bounded by static functions.

-shay.banon

On Wed, Jun 16, 2010 at 7:27 AM, Otis otis.gospodne...@gmail.com wrote:

Hi,

Yeah, I purposely said "basic" simply because I wasn't sure whether
the new "script" stuff can be used to do all those things listed on
http://wiki.apache.org/solr/FunctionQuery. Can it? It would be
great to list a few examples somewhere, so we can get a better idea.

For example, can the "script" functionality be used for these
(randomly picked from the above Wiki page):

http://wiki.apache.org/solr/FunctionQuery#ord
http://wiki.apache.org/solr/FunctionQuery#sum
http://wiki.apache.org/solr/FunctionQuery#recip
http://wiki.apache.org/solr/FunctionQuery#ms
http://wiki.apache.org/solr/FunctionQuery#geohash_-_Convert_to_geohash
http://wiki.apache.org/solr/FunctionQuery#strdist

Thanks,
Otis

Sematext ::http://sematext.com/:: Solr - Lucene - Nutch
Lucene ecosystem search ::http://search-lucene.com/

On Jun 15, 3:30 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Yes, it similar in spirit to function queries, it is actually modeled
after
Lucene custom score query (but not used directly). Why do you say its a
basic version of function queries, is there something you can do with the
other that you can't do with this?

-shay.banon

On Tue, Jun 15, 2010 at 8:17 AM, Otis otis.gospodne...@gmail.com
wrote:

Hi,

So one can put any sort of a custom formula in that "script" value,
ha?

Sounds like the equivalent of Solr's function queries? (
http://wiki.apache.org/solr/FunctionQuery)
Or maybe a basic version of function queries?

Thanks,
Otis

Sematext ::http://sematext.com/::Solr - Lucene - Nutch
Lucene ecosystem search ::http://search-lucene.com/

On Jun 13, 8:19 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

custom_score query support just pushed to master. This allows to
easily
control the scoring (or completely replace) of a query based on the
query
score and other document field values. Much more is explained in the
issue:Query DSL: custom score (scripted) query · Issue #220 · elastic/elasticsearch · GitHub, but
here
is a
simple sample:

"custom_score" : {
"query" : {
....
},
"script" : "score * doc['my_numeric_field'].value"

}

This was requested by several users, for example, to control the
scoring
based on recency of documents.

-shay.banon