From 8432221efa9ef61f4527d79fbb107e72f5757154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20J=C3=A4derberg?= Date: Fri, 20 May 2016 19:29:54 +0200 Subject: [PATCH] Extract lucene-index docs --- community/lucene-index/pom.xml | 15 ---- .../impl/lucene/legacy/TestLuceneIndex.java | 2 - manual/contents/pom.xml | 30 ++++---- manual/contents/src/advanced/index.asciidoc | 4 +- manual/lucene/LICENSES.txt | 4 ++ manual/lucene/NOTICE.txt | 26 +++++++ manual/lucene/pom.xml | 68 ++++++++++++++++++ .../src/docs/dev/batchinsertindex.asciidoc | 21 +++--- .../docs/dev/images/indexing-imdb-example.png | Bin .../lucene}/src/docs/dev/index.asciidoc | 52 +++++++------- .../src/test/java/examples/ImdbDocTest.java | 13 ++-- .../impl/lucene/legacy/TestLuceneIndex.java | 48 +++++++++++++ manual/pom.xml | 1 + 13 files changed, 208 insertions(+), 76 deletions(-) create mode 100644 manual/lucene/LICENSES.txt create mode 100644 manual/lucene/NOTICE.txt create mode 100644 manual/lucene/pom.xml rename {community/lucene-index => manual/lucene}/src/docs/dev/batchinsertindex.asciidoc (73%) rename {community/lucene-index => manual/lucene}/src/docs/dev/images/indexing-imdb-example.png (100%) rename {community/lucene-index => manual/lucene}/src/docs/dev/index.asciidoc (93%) rename {community/lucene-index => manual/lucene}/src/test/java/examples/ImdbDocTest.java (98%) create mode 100644 manual/lucene/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java diff --git a/community/lucene-index/pom.xml b/community/lucene-index/pom.xml index aad755ccc76e..6c17bbf14526 100644 --- a/community/lucene-index/pom.xml +++ b/community/lucene-index/pom.xml @@ -125,21 +125,6 @@ the relevant Commercial Agreement. test - - org.neo4j - neo4j-graphviz - ${project.version} - test - - - - org.neo4j.doc - neo4j-doc-tools - ${project.version} - test - test-jar - - diff --git a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java index 2fa91e7ea107..4268e6e9048a 100644 --- a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java +++ b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java @@ -1573,14 +1573,12 @@ public void exactIndexWithCaseInsensitive() throws Exception @Test public void exactIndexWithCaseInsensitiveWithBetterConfig() throws Exception { - // START SNIPPET: exact-case-insensitive Index index = graphDb.index().forNodes( "exact-case-insensitive", stringMap( "type", "exact", "to_lower_case", "true" ) ); Node node = graphDb.createNode(); index.add( node, "name", "Thomas Anderson" ); assertContains( index.query( "name", "\"Thomas Anderson\"" ), node ); assertContains( index.query( "name", "\"thoMas ANDerson\"" ), node ); - // END SNIPPET: exact-case-insensitive restartTx(); assertContains( index.query( "name", "\"Thomas Anderson\"" ), node ); assertContains( index.query( "name", "\"thoMas ANDerson\"" ), node ); diff --git a/manual/contents/pom.xml b/manual/contents/pom.xml index 98860faa28c5..097ebeab872c 100644 --- a/manual/contents/pom.xml +++ b/manual/contents/pom.xml @@ -55,20 +55,6 @@ docs provided - - org.neo4j - neo4j-lucene-index - ${neo4j.version} - docs - provided - - - org.neo4j - neo4j-lucene-index - ${neo4j.version} - test-sources - provided - org.neo4j neo4j-ha @@ -111,6 +97,20 @@ docs provided + + org.neo4j.doc + neo4j-lucene-index-docs + ${neo4j.version} + docs + provided + + + org.neo4j.doc + neo4j-lucene-index-docs + ${neo4j.version} + test-sources + provided + org.neo4j.doc neo4j-kernel-docs @@ -349,7 +349,7 @@ META-INF,META-INF/**,org/neo4j/kernel/impl/storemigration/legacystore/** jar ${docs.test-sources} - neo4j-cypher-docs,neo4j-examples,neo4j-harness-test,neo4j-server,neo4j-lucene-index,neo4j-backup,neo4j-kernel-docs + neo4j-cypher-docs,neo4j-examples,neo4j-harness-test,neo4j-server,neo4j-lucene-index-docs,neo4j-backup,neo4j-kernel-docs diff --git a/manual/contents/src/advanced/index.asciidoc b/manual/contents/src/advanced/index.asciidoc index 57f5c93be4dc..e1d2e9d9b2cf 100644 --- a/manual/contents/src/advanced/index.asciidoc +++ b/manual/contents/src/advanced/index.asciidoc @@ -27,7 +27,7 @@ include::{importdir}/neo4j-examples-docs-jar/dev/traversal-framework.asciidoc[] :leveloffset: 1 -include::{importdir}/neo4j-lucene-index-docs-jar/dev/index.asciidoc[] +include::{importdir}/neo4j-lucene-index-docs-docs-jar/dev/index.asciidoc[] :leveloffset: 1 @@ -35,5 +35,5 @@ include::{importdir}/neo4j-kernel-docs-docs-jar/dev/batchinsert.asciidoc[] :leveloffset: 2 -include::{importdir}/neo4j-lucene-index-docs-jar/dev/batchinsertindex.asciidoc[] +include::{importdir}/neo4j-lucene-index-docs-docs-jar/dev/batchinsertindex.asciidoc[] diff --git a/manual/lucene/LICENSES.txt b/manual/lucene/LICENSES.txt new file mode 100644 index 000000000000..e62824d7096a --- /dev/null +++ b/manual/lucene/LICENSES.txt @@ -0,0 +1,4 @@ +This file contains the full license text of the included third party +libraries. For an overview of the licenses see the NOTICE.txt file. + + diff --git a/manual/lucene/NOTICE.txt b/manual/lucene/NOTICE.txt new file mode 100644 index 000000000000..2e529f508fb3 --- /dev/null +++ b/manual/lucene/NOTICE.txt @@ -0,0 +1,26 @@ +Neo4j +Copyright © 2002-2016 Network Engine for Objects in Lund AB (referred to +in this notice as "Neo Technology") + [http://neotechnology.com] + +This product includes software ("Software") developed by Neo Technology. + +The software ("Software") is developed and owned by Network Engine +for Objects in Lund AB (referred to in this notice as "Neo Technology"). +If you have executed an End User Software License and Services Agreement, +an OEM Software License and Support Services Agreement, or another +commercial license agreement (including an Evaluation Agreement) with +Neo Technology or one of its affiliates (each, a "Commercial Agreement"), +you may use the Software solely pursuant to the terms of the relevant +Commercial Agreement. + +If you have not executed a Commercial Agreement with Neo Technology, the +Software is subject to the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +Version 3 (http://www.fsf.org/licensing/licenses/agpl-3.0.html), included +in the LICENSE.txt file. + +Full license texts are found in LICENSES.txt. + +Third-party licenses +-------------------- + diff --git a/manual/lucene/pom.xml b/manual/lucene/pom.xml new file mode 100644 index 000000000000..117708f5805e --- /dev/null +++ b/manual/lucene/pom.xml @@ -0,0 +1,68 @@ + + + + parent + org.neo4j + 3.0.7-SNAPSHOT + ../.. + + 4.0.0 + + org.neo4j.doc + neo4j-lucene-index-docs + 3.0.7-SNAPSHOT + + Neo4j - Lucene Index Docs + Documentation build for Neo4j Lucene index integration. + + + + + junit + junit + test + + + org.neo4j + neo4j-lucene-index + ${project.version} + test + + + org.neo4j + neo4j-lucene-index + ${project.version} + test + test-jar + + + org.neo4j + neo4j-kernel + ${project.version} + test + test-jar + + + org.neo4j + neo4j-io + ${project.version} + test + test-jar + + + org.neo4j + neo4j-graphviz + ${project.version} + test + + + org.neo4j.doc + neo4j-doc-tools + ${project.version} + test + test-jar + + + diff --git a/community/lucene-index/src/docs/dev/batchinsertindex.asciidoc b/manual/lucene/src/docs/dev/batchinsertindex.asciidoc similarity index 73% rename from community/lucene-index/src/docs/dev/batchinsertindex.asciidoc rename to manual/lucene/src/docs/dev/batchinsertindex.asciidoc index a0c802f32ce9..a6308ea0b576 100644 --- a/community/lucene-index/src/docs/dev/batchinsertindex.asciidoc +++ b/manual/lucene/src/docs/dev/batchinsertindex.asciidoc @@ -1,15 +1,14 @@ [[indexing-batchinsert]] -Index Batch Insertion -===================== += Index Batch Insertion For general notes on batch insertion, see <>. Indexing during batch insertion is done using link:javadocs/org/neo4j/unsafe/batchinsert/BatchInserterIndex.html[BatchInserterIndex] which are provided via link:javadocs/org/neo4j/unsafe/batchinsert/BatchInserterIndexProvider.html[BatchInserterIndexProvider]. An example: -[snippet,java] +[snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=batchInsert ---- @@ -17,16 +16,18 @@ tag=batchInsert The configuration parameters are the same as mentioned in <>. [[indexing-batchinsert-best-practices]] -== Best practices == +== Best practices -Here are some pointers to get the most performance out of +BatchInserterIndex+: +Here are some pointers to get the most performance out of `BatchInserterIndex`: * Try to avoid link:javadocs/org/neo4j/unsafe/batchinsert/BatchInserterIndex.html#flush%28%29[flushing] too often because each flush will result in all additions (since last flush) to be visible to the querying methods, and publishing those changes can be a performance penalty. * Have (as big as possible) phases where one phase is either only writes or only reads, and don't forget to flush after a write phase so that those changes becomes visible to the querying methods. -* Enable link:javadocs/org/neo4j/unsafe/batchinsert/BatchInserterIndex.html#setCacheCapacity%28java.lang.String,%20int%29[caching] for keys you know you're going to do lookups for later on to increase performance significantly (though insertion performance may degrade slightly). +* Enable link:javadocs/org/neo4j/unsafe/batchinsert/BatchInserterIndex.html#setCacheCapacity%28java.lang.String,%20int%29[caching] for keys that you will later do lookups. + This can significantly increase performance (though insertion performance may degrade slightly). [NOTE] -Changes to the index are available for reading first after they are flushed to disk. -Thus, for optimal performance, read and lookup operations should be kept to a minimum during batchinsertion since they -involve IO and impact speed negatively. +-- +Changes to the index are available for reading first after they are flushed to disk. +Thus, for optimal performance, read and lookup operations should be kept to a minimum during batch insertion since they involve IO and impact speed negatively. +-- diff --git a/community/lucene-index/src/docs/dev/images/indexing-imdb-example.png b/manual/lucene/src/docs/dev/images/indexing-imdb-example.png similarity index 100% rename from community/lucene-index/src/docs/dev/images/indexing-imdb-example.png rename to manual/lucene/src/docs/dev/images/indexing-imdb-example.png diff --git a/community/lucene-index/src/docs/dev/index.asciidoc b/manual/lucene/src/docs/dev/index.asciidoc similarity index 93% rename from community/lucene-index/src/docs/dev/index.asciidoc rename to manual/lucene/src/docs/dev/index.asciidoc index 795bb313998b..471fe952b432 100644 --- a/community/lucene-index/src/docs/dev/index.asciidoc +++ b/manual/lucene/src/docs/dev/index.asciidoc @@ -38,7 +38,7 @@ To set the stage for our examples, let's create some indexes to begin with: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=createIndexes ---- @@ -52,7 +52,7 @@ You can also check if an index exists like this: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=checkIfExists ---- @@ -67,7 +67,7 @@ An index can be created with the same name at a later point in time. [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=delete ---- @@ -84,7 +84,7 @@ To begin with, let's add a few nodes to the indexes: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=createNodes ---- @@ -95,7 +95,7 @@ Next up, we'll create relationships and index them as well: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=createRelationships ---- @@ -116,7 +116,7 @@ link:javadocs/org/neo4j/graphdb/index/Index.html#remove%28T,%20java.lang.String, [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=removeNodeFromIndex ---- @@ -137,7 +137,7 @@ Here's a code example that demonstrates how it's done: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=update ---- @@ -158,7 +158,7 @@ This is how to search for a single exact match: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=getSingleNode ---- @@ -170,7 +170,7 @@ Here's how to get a single relationship by exact matching and retrieve its start [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=getSingleRelationship ---- @@ -179,7 +179,7 @@ Finally, we can iterate over all exact matches from a relationship index: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=getRelationships ---- @@ -197,7 +197,7 @@ Here's an example using the key-query option: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=actorsQuery ---- @@ -206,7 +206,7 @@ In the following example the query uses multiple keys: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=matrixQuery ---- @@ -227,7 +227,7 @@ Example of querying a relationship index: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=queryForRelationships ---- @@ -236,7 +236,7 @@ And here's an example for the special case of searching for a specific relations [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=queryForRelationshipType ---- @@ -255,7 +255,7 @@ See <> for how to sort by score. [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=queryWithScore ---- @@ -269,7 +269,7 @@ For example to create a Lucene fulltext index: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=fulltext ---- @@ -278,7 +278,7 @@ Here's an example of how to create an exact index which is case-insensitive: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java tag=exact-case-insensitive ---- @@ -315,7 +315,7 @@ To mark a value so that it is indexed as a numeric value, we can make use of the [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=numericRange ---- @@ -331,7 +331,7 @@ In the following example we are doing that, and have added sorting to the query [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=sortedNumericRange ---- @@ -340,7 +340,7 @@ From/to in the ranges defaults to be _inclusive_, but you can change this behavi [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=exclusiveRange ---- @@ -354,7 +354,7 @@ Lucene performs sorting very well, and that is also exposed in the index backend [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=sortedResult ---- @@ -363,7 +363,7 @@ We sort the results by relevance (score) like this: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=queryWithRelevance ---- @@ -376,7 +376,7 @@ Instead of passing in Lucene query syntax queries, you can instantiate such quer [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=termQuery ---- @@ -387,7 +387,7 @@ This is how to perform _wildcard_ searches using Lucene query objects: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=wildcardTermQuery ---- @@ -402,7 +402,7 @@ Lucene supports querying for multiple terms in the same query, like so: [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=compoundQueries ---- @@ -417,7 +417,7 @@ The default operator (that is whether +AND+ or +OR+ is used in between different [snippet, java] ---- -component=neo4j-lucene-index +component=neo4j-lucene-index-docs source=examples/ImdbDocTest.java tag=defaultOperator ---- diff --git a/community/lucene-index/src/test/java/examples/ImdbDocTest.java b/manual/lucene/src/test/java/examples/ImdbDocTest.java similarity index 98% rename from community/lucene-index/src/test/java/examples/ImdbDocTest.java rename to manual/lucene/src/test/java/examples/ImdbDocTest.java index f6dc542faeb8..b3166678fc17 100644 --- a/community/lucene-index/src/test/java/examples/ImdbDocTest.java +++ b/manual/lucene/src/test/java/examples/ImdbDocTest.java @@ -5,17 +5,17 @@ * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Affero General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package examples; @@ -645,5 +645,6 @@ public void batchInsert() throws Exception } db.shutdown(); } + } diff --git a/manual/lucene/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java b/manual/lucene/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java new file mode 100644 index 000000000000..2ea826e83c1e --- /dev/null +++ b/manual/lucene/src/test/java/org/neo4j/index/impl/lucene/legacy/TestLuceneIndex.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2016 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.neo4j.index.impl.lucene.legacy; + +import org.junit.Test; + +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.index.Index; +import org.neo4j.helpers.collection.MapUtil; + +import static org.neo4j.index.Neo4jTestCase.assertContains; + +public class TestLuceneIndex extends AbstractLuceneIndexTest { + + @Test + public void exactIndexWithCaseInsensitiveWithBetterConfig() throws Exception + { + // START SNIPPET: exact-case-insensitive + Index index = graphDb.index().forNodes( "exact-case-insensitive", + MapUtil.stringMap( "type", "exact", "to_lower_case", "true" ) ); + Node node = graphDb.createNode(); + index.add( node, "name", "Thomas Anderson" ); + assertContains( index.query( "name", "\"Thomas Anderson\"" ), node ); + assertContains( index.query( "name", "\"thoMas ANDerson\"" ), node ); + // END SNIPPET: exact-case-insensitive + restartTx(); + assertContains( index.query( "name", "\"Thomas Anderson\"" ), node ); + assertContains( index.query( "name", "\"thoMas ANDerson\"" ), node ); + } + +} diff --git a/manual/pom.xml b/manual/pom.xml index d286c8f6799d..da843dce48b6 100644 --- a/manual/pom.xml +++ b/manual/pom.xml @@ -29,6 +29,7 @@ bolt import-tool kernel + lucene