【发布时间】:2013-12-20 10:07:36
【问题描述】:
域类如下:
@NodeEntity
public class Product{
private Long nodeId;
@Indexed(indexName = "productCode")
private String code;
...
}
存储库类:
public interface ProductRepository extends GraphRepository<Product>{
@Query(value="start product=node:productCode(code={0}) return product")
public Set<Product> findProducts(String code);
}
如何使代码查找不区分大小写? 我尝试正则表达式并失败。代码如下:
public interface ProductRepository extends GraphRepository<Product>{
@Query(value="start product=node:productCode(code=~{0}) return product")
public Set<Product> findProducts(String code);
}
我知道一种方法可行,但性能不佳,代码如下:
public interface ProductRepository extends GraphRepository<Product>{
@Query(value="start product=node:__types__(className='Product') where product.code='~{0}' return product")
public Set<Product> findProducts(String code);
}
【问题讨论】:
-
您是否尝试过制作索引全文并提供整个 lucene 查询作为参数?在@indexed 注释中设置
type=indexType.FULLTEXT,将code={0}替换为{0},并将每个lucene.apache.org/core/3_6_2/queryparsersyntax.html 的查询字符串传递给findProducts方法。已经有一段时间了,但我认为通配符查询不区分大小写,因此传递“code:PrOdUcTcOdE*”之类的内容应该可以工作。
标签: java indexing neo4j cypher spring-data-neo4j