简体   繁体   中英

how to set limit searching node in restapifacade for neo4j

the below code is working perfectly

public void restSearch(String term) {
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes("node_auto_index");
        IndexHits<Node> hits = actors.query("name", term + "*");
        JSONArray json_arr = new JSONArray();
        for (Node node : hits) {
                System.out.println(node.getProperty("name"));
        }

    }

but it gives me too much result i want to set limit. i want only 20 names.

can i optimize this query and set limit here

IndexHits<Node> hits = actors.query("name", term + "*");

Use cypher:

String query = "START n=node: node_auto_index({query}) RETURN n.name";

restApi.query(query,map("query","name:"+term+"*"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM