`

Neo4j: fulltext search

 
阅读更多

Model

    @Indexed(indexType = IndexType.FULLTEXT, indexName = "TaskTile")
    private String title;

 

Repository

    @Query("START n=node:TaskTile({0}) return n")
    Iterable<Task> findTasksByTitle(String query);

 

query string parameter

title:*software*

 

In SDN mauanl guaid, the following codes can't work

 

Result<Task> tasks = taskRepo.findAllByQuery("TaskTitle",  skill);

 

However, I want to search Task by title property using multipy keywords suck like

[software\flower\gun]

This method doesn't work. We must split the keywords into single word and pass it to the query.

 

Another solution may be use  Neo4j primitive  Index API.

 

try (Transaction tx = template.getGraphDatabaseService().beginTx()) {
    IndexManager index = db.index();
    Index<Node> taskTitleIndex = index.forNodes("TaskTile");
    IndexHits<Node> hits = taskTitleIndex.query("title:*software*  OR  title:*数据*");
    for(Node hit : hits){
	logger.info(" found task:"+ hit.getProperty("title"));
    }
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

References

http://stackoverflow.com/questions/19872571/spring-data-neo4j-fulltext-index-in-cypher-query

 http://neo4j.com/docs/stable/indexing-lucene-extras.html

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics