Package net.joshdevins.elasticsearch.scorer

Source Code of net.joshdevins.elasticsearch.scorer.RandomScoreFactory

package net.joshdevins.elasticsearch.scorer;

import java.util.Map;
import java.util.Random;

import org.elasticsearch.common.Nullable;
import org.elasticsearch.script.AbstractDoubleSearchScript;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;

/**
* Scores by a random value.
*/
public final class RandomScoreFactory implements NativeScriptFactory {

    static private Random RND = new Random(System.currentTimeMillis());

    @Override
    public ExecutableScript newScript(@Nullable Map<String, Object> params) {
        return new AbstractDoubleSearchScript() {

            @Override
            public double runAsDouble() {
                return RND.nextDouble();
            }
        };
    }

}
TOP

Related Classes of net.joshdevins.elasticsearch.scorer.RandomScoreFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.