lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rohit Agarwal <>
Subject Sorting Problem with custom ValueSourceParser
Date Tue, 04 Oct 2016 18:41:46 GMT
I am writing a custom ValueSourceParser. Everything is working fine except
when i use valuesourceparser for sorting it stops working for calls with
different data.

Eg: if i make a query to sort by func(cost) desc
It works.
Now if i change cost with some another field eg func(rating) desc
It sorts the result by cost only.

Now if i restart the solr server and call sort by func(rating) it works but
now it will stick with rating

Any idea why this would be happening?


public class MySourceParser extends ValueSourceParser {

    public void init(NamedList args) {

    public ValueSource parse(FunctionQParser functionQParser) throws
SyntaxError {
        ValueSource source = functionQParser.parseValueSource();
        String val = functionQParser.parseArg();
        return new MySource(source, val);

    public class MySource extends ValueSource {

        private ValueSource source;
        private String val;

        public MySource(ValueSource source, String val) {
            this.source = source;
            this.val = val;

        public FunctionValues getValues(Map map, LeafReaderContext
leafReaderContext) throws IOException {
            FunctionValues functionValues = source.getValues(map,
            return new IntDocValues(this) {
                public int intVal(int i) {
                    return functionValues.intVal(i);

        public void createWeight(Map context, IndexSearcher searcher)
throws IOException {
            source.createWeight(context, searcher);

        public boolean equals(Object o) {
            return true;

        public int hashCode() {
            return this.hashCode();

        public String description() {
            return "testing";

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message