func makeRange(lhs *gentypes.FieldType, op lex.TokenType, rhs expr.Node) (interface{}, error) {
	rhsval, ok := scalar(rhs)
	if !ok {
		return nil, fmt.Errorf("qlindex: unsupported type for comparison: %T", rhs)
	}

	// Convert scalars from strings to floats if lhs is numeric and rhs is a
	// float (ES handles ints as strings just fine).
	if lhs.Numeric() {
		if rhsstr, ok := rhsval.(string); ok {
			if rhsf, err := strconv.ParseFloat(rhsstr, 64); err == nil {
				// rhsval can be converted to a float!
				rhsval = rhsf
			}
		}
	}

	/*
		"nested": {
			"filter": {
			    "term": {
			        "map_actioncounts.k": "Web hit"
			    }
			},
			"path": "map_actioncounts"
		}

		"nested": {
			"filter": {
			    "and": [
			        {
			            "term": {
			                "mapvals_fields.k": "has_data"
			            }
			        },
			        {
			            "term": {
			                "mapvals_fields.b": true
			            }
			        }
			    ]
			},
			"path": "mapvals_fields"
		}
		"nested": {
			"filter": {
			    "and": [
			        {
			            "term": {
			                "k": "open"
			            }
			        },
			        {
			            "range": {
			                "f": {"gte": 7}
			            }
			        }
			    ]
			},
			"path": "map_events"
		}
		q = esMap{"nested": esMap{"path": parent, "filter": esMap{"and": []esMap{
					{"term": esMap{parent + ".k": child}},
					{"range": esMap{parent + valuePath: esMap{esRangeOps[seg.SegType]: rhsNum}}},
				}}}}
	*/

	fieldName := lhs.Field
	if lhs.Nested() {
		fieldName, rhsval = lhs.PrefixAndValue(rhsval)
	}
	r := &RangeFilter{}
	switch op {
	case lex.TokenGE:
		r.Range = map[string]RangeQry{fieldName: {GTE: rhsval}}
	case lex.TokenLE:
		r.Range = map[string]RangeQry{fieldName: {LTE: rhsval}}
	case lex.TokenGT:
		r.Range = map[string]RangeQry{fieldName: {GT: rhsval}}
	case lex.TokenLT:
		r.Range = map[string]RangeQry{fieldName: {LT: rhsval}}
	default:
		return nil, fmt.Errorf("qlindex: unsupported range operator %s", op)
	}
	if lhs.Nested() {
		return Nested(lhs, r), nil
	}
	return r, nil
}
// makeRange returns a range filter for Elasticsearch given the 3 nodes that
// make up a comparison.
makeRange returns a range filter for Elasticsearch given the 3 nodes that
make up a comparison.
// makeRange returns a range filter for Elasticsearch given the 3 nodes that // make up a comparison .
func makeRange(lhs *gentypes.FieldType, op lex.TokenType, rhs expr.Node) (interface{}, error) {
	rhsval, ok := scalar(rhs)
	if !ok {
		return nil, fmt.Errorf("qlindex: unsupported type for comparison: %T", rhs)
	}
	if lhs.Numeric() {
		if rhsstr, ok := rhsval.(string); ok {
			if rhsf, err := strconv.ParseFloat(rhsstr, 64); err == nil {
				rhsval = rhsf
			}
		}
	}
	fieldName := lhs.Field
	if lhs.Nested() {
		fieldName, rhsval = lhs.PrefixAndValue(rhsval)
	}
	r := &RangeFilter{}
	switch op {
	case lex.TokenGE:
		r.Range = map[string]RangeQry{fieldName: {GTE: rhsval}}
	case lex.TokenLE:
		r.Range = map[string]RangeQry{fieldName: {LTE: rhsval}}
	case lex.TokenGT:
		r.Range = map[string]RangeQry{fieldName: {GT: rhsval}}
	case lex.TokenLT:
		r.Range = map[string]RangeQry{fieldName: {LT: rhsval}}
	default:
		return nil, fmt.Errorf("qlindex: unsupported range operator %s", op)
	}
	if lhs.Nested() {
		return Nested(lhs, r), nil
	}
	return r, nil
}
func makeRange ( lhs * gentypes . FieldType , op lex . TokenType , rhs expr . Node ) ( interface { } , error ) { rhsval , ok := scalar ( rhs ) if ! ok { return nil , fmt . Errorf ( " " , rhs ) } if lhs . Numeric ( ) { if rhsstr , ok := rhsval . ( string ) ; ok { if rhsf , err := strconv . ParseFloat ( rhsstr , 64 ) ; err == nil { rhsval = rhsf } } } fieldName := lhs . Field if lhs . Nested ( ) { fieldName , rhsval = lhs . PrefixAndValue ( rhsval ) } r := & RangeFilter { } switch op { case lex . TokenGE : r . Range = map [ string ] RangeQry { fieldName : { GTE : rhsval } } case lex . TokenLE : r . Range = map [ string ] RangeQry { fieldName : { LTE : rhsval } } case lex . TokenGT : r . Range = map [ string ] RangeQry { fieldName : { GT : rhsval } } case lex . TokenLT : r . Range = map [ string ] RangeQry { fieldName : { LT : rhsval } } default : return nil , fmt . Errorf ( " " , op ) } if lhs . Nested ( ) { return Nested ( lhs , r ) , nil } return r , nil }
makeRange returns a range filter for Elasticsearch given the 3 nodes that
make up a comparison.
makeRange returns a range filter for Elasticsearch given the 3 nodes that make up a comparison .
// Convert scalars from strings to floats if lhs is numeric and rhs is a // float (ES handles ints as strings just fine). // rhsval can be converted to a float! /*
		"nested": {
			"filter": {
			    "term": {
			        "map_actioncounts.k": "Web hit"
			    }
			},
			"path": "map_actioncounts"
		}

		"nested": {
			"filter": {
			    "and": [
			        {
			            "term": {
			                "mapvals_fields.k": "has_data"
			            }
			        },
			        {
			            "term": {
			                "mapvals_fields.b": true
			            }
			        }
			    ]
			},
			"path": "mapvals_fields"
		}
		"nested": {
			"filter": {
			    "and": [
			        {
			            "term": {
			                "k": "open"
			            }
			        },
			        {
			            "range": {
			                "f": {"gte": 7}
			            }
			        }
			    ]
			},
			"path": "map_events"
		}
		q = esMap{"nested": esMap{"path": parent, "filter": esMap{"and": []esMap{
					{"term": esMap{parent + ".k": child}},
					{"range": esMap{parent + valuePath: esMap{esRangeOps[seg.SegType]: rhsNum}}},
				}}}}
	*/