[Neo4j] Default Analyzer in Index Framework

Mattias Persson mattias at neotechnology.com
Wed Oct 26 01:08:36 CEST 2011


Hi Rick,

yes you can do that, but not in a super easy way. What you'd have to do
right now to get it working is to make sure you create an index with a
special analyzer which converts everything to lower case (both additions and
queries), effectively making it case insensitive. So create a class like
this:

    public class LowerCaseAnalyzer extends Analyzer
    {
        @Override
        public TokenStream tokenStream( String fieldName, Reader reader )
        {
            return new LowerCaseFilter( Version.LUCENE_31, new
KeywordTokenizer( reader ) );
        }
    }

and make sure you create your index with a configuration map like:

    Index<Node> index = graphDb.index().forNodes(
            "myCaseInsensitiveIndex", MapUtil.stringMap( "analyzer",
LowerCaseAnalyzer.class.getName() ) );

then this will work:

    index.add( node, "name", "Rick Bullotta" );
    index.query( "name:\"rick bullotta\"" ); // ==> returns that node.

2011/10/25 Rick Bullotta <rick.bullotta at thingworx.com>

> Anyone able to provide some insights on this?
>
> Thanks.
> ________________________________________
> From: user-bounces at lists.neo4j.org [user-bounces at lists.neo4j.org] On
> Behalf Of Rick Bullotta [rick.bullotta at thingworx.com]
> Sent: Monday, October 24, 2011 6:16 PM
> To: Neo4j user discussions
> Subject: [Neo4j] Default Analyzer in Index Framework
>
> When not using fulltext indexing, what Lucene Analyzer class does Neo4J
> use?  It seems that non-fulltext index searches are case sensitive - we'd
> like to change that behavior.
>
> Thanks for any help/guidance/examples!
>
> Rick
>
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [mattias at neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com


More information about the User mailing list