use of com.yelp.nrtsearch.server.luceneserver.field.FieldDefBindings in project nrtsearch by Yelp.
the class JsScriptBindingsTest method testExtendedInvalidName.
@Test(expected = IllegalArgumentException.class)
public void testExtendedInvalidName() {
Map<String, Object> params = new HashMap<>();
params.put("param1", 100);
params.put("param2", 1.11);
DoubleValuesSource field1Source = new DummyValuesSource();
DoubleValuesSource field2Source = new DummyValuesSource();
Map<String, FieldDef> fieldDefMap = new HashMap<>();
fieldDefMap.put("field1", new VirtualFieldDef("field1", field1Source));
fieldDefMap.put("field2", new VirtualFieldDef("field2", field2Source));
JsScriptBindings bindings = new JsScriptBindings(new FieldDefBindings(fieldDefMap), params);
bindings.getDoubleValuesSource("doc['invalid'].value");
}
use of com.yelp.nrtsearch.server.luceneserver.field.FieldDefBindings in project nrtsearch by Yelp.
the class JsScriptBindingsTest method testGetBindingForField.
@Test
public void testGetBindingForField() {
Map<String, Object> params = new HashMap<>();
params.put("param1", 100);
params.put("param2", 1.11);
DoubleValuesSource field1Source = new DummyValuesSource();
DoubleValuesSource field2Source = new DummyValuesSource();
Map<String, FieldDef> fieldDefMap = new HashMap<>();
fieldDefMap.put("field1", new VirtualFieldDef("field1", field1Source));
fieldDefMap.put("field2", new VirtualFieldDef("field2", field2Source));
JsScriptBindings bindings = new JsScriptBindings(new FieldDefBindings(fieldDefMap), params);
DoubleValuesSource f1Source = bindings.getDoubleValuesSource("field1");
DoubleValuesSource f2Source = bindings.getDoubleValuesSource("field2");
assertNotSame(f1Source, f2Source);
assertSame(f1Source, field1Source);
assertSame(f2Source, field2Source);
}
use of com.yelp.nrtsearch.server.luceneserver.field.FieldDefBindings in project nrtsearch by Yelp.
the class JsScriptBindingsTest method testParamBindingIsCached.
@Test
public void testParamBindingIsCached() {
Map<String, Object> params = new HashMap<>();
params.put("param1", 100);
params.put("param2", 1.11);
JsScriptBindings bindings = new JsScriptBindings(new FieldDefBindings(Collections.emptyMap()), params);
DoubleValuesSource p1Source = bindings.getDoubleValuesSource("param1");
DoubleValuesSource p2Source = bindings.getDoubleValuesSource("param2");
DoubleValuesSource p1SourceNext = bindings.getDoubleValuesSource("param1");
DoubleValuesSource p2SourceNext = bindings.getDoubleValuesSource("param2");
assertNotSame(p1Source, p2Source);
assertSame(p1Source, p1SourceNext);
assertSame(p2Source, p2SourceNext);
}
use of com.yelp.nrtsearch.server.luceneserver.field.FieldDefBindings in project nrtsearch by Yelp.
the class JsScriptBindingsTest method testInvalidName.
@Test(expected = IllegalArgumentException.class)
public void testInvalidName() {
Map<String, Object> params = new HashMap<>();
params.put("param1", 100);
params.put("param2", 1.11);
DoubleValuesSource field1Source = new DummyValuesSource();
DoubleValuesSource field2Source = new DummyValuesSource();
Map<String, FieldDef> fieldDefMap = new HashMap<>();
fieldDefMap.put("field1", new VirtualFieldDef("field1", field1Source));
fieldDefMap.put("field2", new VirtualFieldDef("field2", field2Source));
JsScriptBindings bindings = new JsScriptBindings(new FieldDefBindings(fieldDefMap), params);
bindings.getDoubleValuesSource("invalid");
}
use of com.yelp.nrtsearch.server.luceneserver.field.FieldDefBindings in project nrtsearch by Yelp.
the class JsScriptBindingsTest method testExtendedMissingProperty.
@Test(expected = IllegalArgumentException.class)
public void testExtendedMissingProperty() {
Map<String, Object> params = new HashMap<>();
params.put("param1", 100);
params.put("param2", 1.11);
DoubleValuesSource field1Source = new DummyValuesSource();
DoubleValuesSource field2Source = new DummyValuesSource();
Map<String, FieldDef> fieldDefMap = new HashMap<>();
fieldDefMap.put("field1", new VirtualFieldDef("field1", field1Source));
fieldDefMap.put("field2", new VirtualFieldDef("field2", field2Source));
JsScriptBindings bindings = new JsScriptBindings(new FieldDefBindings(fieldDefMap), params);
bindings.getDoubleValuesSource("doc['field1']");
}
Aggregations