List of usage examples for org.apache.lucene.queries.function ValueSource hashCode
@Override
public abstract int hashCode();
From source file:org.apache.solr.schema.PolyFieldTest.java
License:Apache License
@Test public void testPointFieldType() throws Exception { SolrCore core = h.getCore();/*w w w. j av a 2s .c om*/ IndexSchema schema = core.getLatestSchema(); SchemaField home = schema.getField("home"); assertNotNull(home); assertTrue("home is not a poly field", home.isPolyField()); FieldType tmp = home.getType(); assertTrue(tmp instanceof PointType); PointType pt = (PointType) tmp; assertEquals(pt.getDimension(), 2); double[] xy = new double[] { 35.0, -79.34 }; String point = xy[0] + "," + xy[1]; List<IndexableField> fields = home.createFields(point, 2); assertEquals(fields.size(), 3);//should be 3, we have a stored field //first two fields contain the values, third is just stored and contains the original for (int i = 0; i < 3; i++) { boolean hasValue = fields.get(i).binaryValue() != null || fields.get(i).stringValue() != null || fields.get(i).numericValue() != null; assertTrue("Doesn't have a value: " + fields.get(i), hasValue); } /*assertTrue("first field " + fields[0].tokenStreamValue() + " is not 35.0", pt.getSubType().toExternal(fields[0]).equals(String.valueOf(xy[0]))); assertTrue("second field is not -79.34", pt.getSubType().toExternal(fields[1]).equals(String.valueOf(xy[1]))); assertTrue("third field is not '35.0,-79.34'", pt.getSubType().toExternal(fields[2]).equals(point));*/ home = schema.getField("home_ns"); assertNotNull(home); fields = home.createFields(point, 2); assertEquals(fields.size(), 2);//should be 2, since we aren't storing home = schema.getField("home_ns"); assertNotNull(home); try { fields = home.createFields("35.0,foo", 2); assertTrue(false); } catch (Exception e) { // } // SchemaField s1 = schema.getField("test_p"); SchemaField s2 = schema.getField("test_p"); ValueSource v1 = s1.getType().getValueSource(s1, null); ValueSource v2 = s2.getType().getValueSource(s2, null); assertEquals(v1, v2); assertEquals(v1.hashCode(), v2.hashCode()); }