【问题标题】:spring neo4j: how can I search data by index field case insensitive?spring neo4j:如何按索引字段不区分大小写搜索数据?
【发布时间】: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


【解决方案1】:

一种方法是尝试使用带有正则表达式的 where 子句:

查看latest 2.0 milestonehere for 1.9.5

【讨论】:

  • 感谢您的回复。以下查询有效,但我认为随着代码被索引,性能应该会降低。 @Query(value="start product=node:__types__(className='Product') where product.code='~{0}' return product").
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-05
  • 2010-10-28
  • 2017-02-09
  • 1970-01-01
相关资源
最近更新 更多