spring neo4j: how can I search data by index field case insensitive?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 00:11:45

问题


Domain class as following:

@NodeEntity
public class Product{

   private Long nodeId;
   @Indexed(indexName = "productCode")
   private String code;
   ...
}

Repository class:

 public interface ProductRepository extends GraphRepository<Product>{       
       @Query(value="start product=node:productCode(code={0}) return product")
        public Set<Product> findProducts(String code);
    }

how can I make code lookup case insensitive? I try regular expression and fail.Code as following:

 public interface ProductRepository extends GraphRepository<Product>{

       @Query(value="start product=node:productCode(code=~{0}) return product")
        public Set<Product> findProducts(String code);
    }

I know one way works but the performance will be not good, the code as following:

 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);
            }

回答1:


One way would be to try and use where clause with regular expressions:

See the latest 2.0 milestone or here for 1.9.5



来源:https://stackoverflow.com/questions/20701091/spring-neo4j-how-can-i-search-data-by-index-field-case-insensitive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!