I have a common entity class:
@NodeEntity
public class Entity {
/*** Common Fields ***/
@GraphId
protected Long nodeId;
@Indexed(level = Indexed.Level.INSTANCE)
protected Long id;
@Indexed(level = Indexed.Level.INSTANCE)
protected String someProperty;
...
}
An Employee class extending Entiy class:
public class Employee extends Entity {
@Indexed
private String someOtherProperty;
...
}
I have noticed in my tests that:
@Autowired private GraphDatabaseService service;
Node node1 = service.index().forNodes("Employee").get("id", 1l).getSingle();
does not return any value, while
Node node2 = service.index().forNodes("Employee").get("someProperty", "someValue").getSingle();
Node node3 = service.index().forNodes("Employee").get("someOtherProperty", "someOtherValue").getSingle();
both returns as expected.
I tried changing the name of “id” to some other literal and both searching with 1 (numeric) and with “1” (String) but it’s still the same case. I suspect it has something to do with numeric values.
So I wonder maybe I’m using @Indexed in a wrong fashion?
Using:
neo4j-version: 1.8
spring-data-neo4j.version: 2.1.0.RC4
Indexing of numeric fields defaults to numeric values which are then stored in lucene differently, that means one has to use
NumericRangeQuery, this is done internally in theNeo4jTemplate.lookupmethod.If you don’t want to index the data numerically use
@Indexed(numeric=false). Then it is indexed as a String and found by cypher and string index lookups.