Hi,

I'm playing around with indexing and numeric range queries according to 
this documentation:

   http://docs.neo4j.org/chunked/snapshot/indexing-lucene-extras.html

According to my tests numeric range queries 
(QueryContext.numericRange()) only have effect when "exact" type index 
is used.


I tried this:

Transaction tx = graphDb.beginTx();
try {

   Index<Node> exactIndex = graphDb.index().forNodes("exactIndex", 
MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "exact" ));
   Index<Node> fulltextIndex = graphDb.index().forNodes("fulltextIndex", 
MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ));

   Node n1 = graphDb.createNode();
   n1.setProperty("foo", 5);
   exactIndex.add(n1, "foo", ValueContext.numeric(5));
   fulltextIndex.add(n1, "foo", ValueContext.numeric(5));

   Node n2 = graphDb.createNode();
   n2.setProperty("foo", 25);
   exactIndex.add(n2, "foo", ValueContext.numeric(25));
   fulltextIndex.add(n2, "foo", ValueContext.numeric(25));

   // Force commit
   tx.success();
   tx.finish();
   tx = graphDb.beginTx();

   //Search exact
   QueryContext qctx = QueryContext.numericRange("foo", 3, 25);
   IndexHits<Node> hits = exactIndex.query(qctx);
   Iterator<Node> it = hits.iterator();
   while (it.hasNext()) {
       Node n = it.next();
       System.out.println("Found foo in exact: "+n+": 
"+n.getProperty("foo"));
   }
   assertEquals(2, hits.size());

   //Search fulltext
   qctx = QueryContext.numericRange("foo", 3, 25);
   hits = fulltextIndex.query(qctx);
   it = hits.iterator();
   while (it.hasNext()) {
       Node n = it.next();
       System.out.println("Found foo in fulltext: "+n+": 
"+n.getProperty("foo"));
   }
   assertEquals(2, hits.size());

   tx.success();
} finally {
   tx.finish();
}

For the "exact" configured index the range query returns two nodes, 
while in "fulltext" configured index I get no result.

Is there a way to use numeric range queries with fulltext indexes?

Thanks for any hints,
---
balazs
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to