Hi Yaniv,

didn't try your case, just read the code. If I remember correctly, it may help 
to expand your search term "director john" into a Lucene query, e.g. something 
like "\"director\" OR \"john\"".

The complete Lucene query syntax see [1].

Greetings

Axel

[1] http://lucene.apache.org/java/3_1_0/queryparsersyntax.html

Am 07.09.2011 um 12:16 schrieb Yaniv Ben Yosef:

> Hi,
> 
> This question may be Lucene related, but since I'm using it via Neo4J I'm
> asking here first. I'm using Neo4J 1.4 M06.
> I have a graph representing people, with a few properties about each person
> (e.g., their name and job title).
> Now I'd like to create a search form that will allow the user to enter
> either the person's first name, last name, title, or any combination. For
> example, the query [john director] should result with all the people whose
> name or title contain both john and director.
> To play with that, I created this little psvm:
> 
> public class FullTextIndexTest
> {
>    public static void main(String[] args)
>    {
>        GraphDatabaseService graphDb =
> GraphDatabaseServiceFactory.createGraphDatabase("target/var/db");
> 
>        Transaction t = graphDb.beginTx();
>        Node n1 = graphDb.createNode();
>        n1.setProperty("name", "John Smith");
>        n1.setProperty("title", "Directory Manager");
> 
>        Node n2 = graphDb.createNode();
>        n2.setProperty("name", "Johnny Malkovich");
>        n2.setProperty("title", "Director of R&D");
> 
>        Node n3 = graphDb.createNode();
>        n3.setProperty("name", "John Horovich");
>        n3.setProperty("title", "Sr. Director");
> 
>        IndexManager index = graphDb.index();
>        Index<Node> fulltextPerson = index.forNodes("person-fulltext",
>                MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
> "fulltext"));
>        fulltextPerson.add(n1, "combined", n1.getProperty("name") + " " +
> n1.getProperty("title"));
>        fulltextPerson.add(n2, "combined", n2.getProperty("name") + " " +
> n2.getProperty("title"));
>        fulltextPerson.add(n3, "combined", n3.getProperty("name") + " " +
> n3.getProperty("title"));
>        t.success();
>        t.finish();
> 
>        // search in the fulltext index
>        IndexHits<Node> hits = fulltextPerson.query("combined", "director
> john");
>        System.out.printf("Found %d results:\n", hits.size());
>        for (Node node : hits)
>        {
>            System.out.println(node.getProperty("name") + ", " +
> node.getProperty("title"));
>        }
>    }
> }
> 
> 
> I expected this program to return 1 result: John Horovich, Sr. Director
> Instead, I'm getting 3:
> 
> John Horovich, Sr. Director
> John Smith, Directory Manager
> Johnny Malkovich, Director of R&D
> 
> It seems that Lucene will "accept" terms that contain a query term (e.g,
> Directory and Johnny) even if I'm not using any wildcards in my query. How
> do I turn this behavior off? I'd like the results to contain only people
> whose name or title *contain* the word john, but not johnny.
> 
> Thanks!
> --- Yaniv
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user


_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to