class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
You don't have to implement native (Java) script, you can simply use script sorting (SearchRequestBuilder#addSort, with SortBuilders as factory), or custom score script.
On Wednesday, January 25, 2012 at 10:23 AM, Karussell wrote:
You can use a boost script with parameters and implement
NativeScriptFactory.
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
Question: my app is connected to a remote Elasitcsearch server (via
TransportClient). Where does this Java class need to exist -- only on
my client, or on the server as well?
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
Which classes? All the search related classes are part of the elasticsearch jar.
On Wednesday, January 25, 2012 at 7:07 PM, Frank LaRosa wrote:
Thanks for the reply.
Question: my app is connected to a remote Elasitcsearch server (via
TransportClient). Where does this Java class need to exist -- only on
my client, or on the server as well?
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
The example provided by Peter shows a custom class (class
BoostSearchScript implements NativeScriptFactory). It's unclear to me
whether this class must be installed at the server or if it just needs
to be available on the client.
He also mentions changing a configuration file -- again, is this a
server-side configuration change or client-side?
I'd rather not have to make server-side changes, since it greatly adds
to the complexity of maintaining my environment.
Which classes? All the search related classes are part of the elasticsearch jar.
On Wednesday, January 25, 2012 at 7:07 PM, Frank LaRosa wrote:
Thanks for the reply.
Question: my app is connected to a remote Elasitcsearch server (via
TransportClient). Where does this Java class need to exist -- only on
my client, or on the server as well?
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
You don't have to implement native (Java) script, you can simply use script sorting (SearchRequestBuilder#addSort, with SortBuilders as factory), or custom score script.
On Wednesday, January 25, 2012 at 10:23 AM, Karussell wrote:
You can use a boost script with parameters and implement
NativeScriptFactory.
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
You don't have to implement native (Java) script, you can simply use script sorting (SearchRequestBuilder#addSort, with SortBuilders as factory), or custom score script.
On Wednesday, January 25, 2012 at 10:23 AM, Karussell wrote:
You can use a boost script with parameters and implement
NativeScriptFactory.
class BoostSearchScript implements NativeScriptFactory {
@Override public ExecutableScript newScript(final Map<String, Object>
params) {
// friends is of type ArrayList as it was serialized via json
even it was Set before
final Collection friends = (Collection)
params.get("friends");
return new AbstractFloatSearchScript() {
@Override public float runAsFloat() {
float ret =
doc().numeric("myPreCalculatedScore").getFloatValue();
// use params here somehow
return ret * friends.size();
}};
...
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.