Full Text Index

93 views
Skip to first unread message

Meeraj Kunnumpurath

unread,
Apr 29, 2012, 4:07:56 PM4/29/12
to ne...@googlegroups.com
Hi,

I am quite new to Neo4J and have been looking at using full-text searches on Nodes using Lucene. I have a few queries around this, some are a bit basic, so please excuse my ignorance.

1. Index Configuration

I specify the index configuration using graphDb.index().forNodes("books", MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" )), when I get the index to add a node to the index. Do I need to repeat the configuration, when I get the same index later to query it. Or is it sufficient to just do graphDb.index().forNodes("books")

2. Multi Attribute Indexes

I am using one index using Lucene on two attributes (name of the book and the category). Is there anyway, I can query across the two attributes in one query? Currently, I concatenate values of both attributes and store them against one key in the index, and search against that key.

3. Ignoring Common Terms

How do I get Lucene query to ignore common terms in the search text. Currently I can get it work with "Tempest" and "Shakespeare", however it doesn't fetch anything if I try "Tempest by Shakespeare"

4. When any of the searchable attributes change, what is the best way to update the index?

5. In general, for fulltext and otherwise, is there a way of auto-indexing properties?

Regards
Meeraj

Meeraj Kunnumpurath

unread,
May 1, 2012, 4:07:43 PM5/1/12
to ne...@googlegroups.com
Hi,

It would be quite helpful, if someone could please offer some pointers on the below questions.

Kind regards
Meeraj

Stefan Armbruster

unread,
May 1, 2012, 5:02:43 PM5/1/12
to ne...@googlegroups.com
Am 29.04.2012 22:07, schrieb Meeraj Kunnumpurath:
> Hi,
>
> I am quite new to Neo4J and have been looking at using full-text
> searches on Nodes using Lucene. I have a few queries around this, some
> are a bit basic, so please excuse my ignorance.
>
> 1. Index Configuration
>
> I specify the index configuration using
> graphDb.index().forNodes("books", MapUtil.stringMap(
> IndexManager.PROVIDER, "lucene", "type", "fulltext" )), when I get the
> index to add a node to the index. Do I need to repeat the configuration,
> when I get the same index later to query it. Or is it sufficient to just
> do graphDb.index().forNodes("books")
IMHO it's sufficient to supply the parameter upon initial index creation.
>
> 2. Multi Attribute Indexes
>
> I am using one index using Lucene on two attributes (name of the book
> and the category). Is there anyway, I can query across the two
> attributes in one query? Currently, I concatenate values of both
> attributes and store them against one key in the index, and search
> against that key.
you can store multiple attribute into the same index:
index.add(node, 'name', <value1>);
index.add(node, 'category', <value2>);
querying can then be done using regular lucene syntax
index.query("name:\"<value1>\" AND body:\"<value2>\"")

>
> 3. Ignoring Common Terms
>
> How do I get Lucene query to ignore common terms in the search text.
> Currently I can get it work with "Tempest" and "Shakespeare", however it
> doesn't fetch anything if I try "Tempest by Shakespeare"
You can supply an 'analyzer' parameter on index creation. See bottom of
http://docs.neo4j.org/chunked/stable/indexing-create-advanced.html.
>
> 4. When any of the searchable attributes change, what is the best way to
> update the index?
Using the autoindexer.
>
> 5. In general, for fulltext and otherwise, is there a way of
> auto-indexing properties?
That's a little bit tricky. Before creation of any autoindex you have to use
graphDb.index().forNodes("node_auto_index", <parameters>) and
graphDb.index().forNodes("relationship_auto_index", <parameters>)


Regards,
Stefan

>
> Regards
> Meeraj


Meeraj Kunnumpurath

unread,
May 1, 2012, 6:47:14 PM5/1/12
to ne...@googlegroups.com
Thanks Stefan. That was very helpful. Just a final question on auto index ..

Is it that I just use the suffix auto_index in the name of the index? If yes how do I get it to index only certain kinds of nodes and also where do I specify the attributes I want to be indexed?

Kind regards
Meeraj

Peter Neubauer

unread,
May 2, 2012, 3:10:28 AM5/2/12
to ne...@googlegroups.com
Meeraj,
there is documentation on this over at
http://docs.neo4j.org/chunked/snapshot/auto-indexing.html. So,
autoindexing works on properties, every node/rel that has the
configured properties will be indexed. For finer control, like only
indexing certain nodes that have the same property, you probably
should use manual indexing which gives you full flexibility in this
area.

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

Meeraj Kunnumpurath

unread,
May 2, 2012, 3:59:37 AM5/2/12
to ne...@googlegroups.com
Thank you.

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages