From: <tho...@us...> - 2014-01-18 23:00:49
|
Revision: 7814 http://bigdata.svn.sourceforge.net/bigdata/?rev=7814&view=rev Author: thompsonbry Date: 2014-01-18 23:00:38 +0000 (Sat, 18 Jan 2014) Log Message: ----------- Resolution for #803 (prefixMatch does not work in full text search). The root cause was a change in how this feature is invoked. It is now indicated by a wildcard in the bsd:search literal. Added a unit test for the simplified version of this syntax. Cleaned up many references to bd:search. The default namespace for this is now bds. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchInSearchOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/store/BDS.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/service/TestSearch.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match2.rq Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchInSearchOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchInSearchOptimizer.java 2014-01-17 15:38:51 UTC (rev 7813) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchInSearchOptimizer.java 2014-01-18 23:00:38 UTC (rev 7814) @@ -29,7 +29,6 @@ import java.util.Map; -import org.apache.log4j.Logger; import org.openrdf.model.Literal; import com.bigdata.bop.Constant; @@ -54,26 +53,28 @@ import com.bigdata.search.IHit; /** - * Converts a BDS.SEARCH_IN_SEARCH function call (inside a filter) - * into an IN filter using the full text index to determine the IN - * set. + * Converts a {@link BDS#SEARCH_IN_SEARCH} function call (inside a filter) into + * an IN filter using the full text index to determine the IN set. * * Convert: * + * <pre> * filter(<BDS.SEARCH_IN_SEARCH>(?o,"foo")) . + * </pre> * * To: * + * <pre> * filter(?o IN ("foo", "foo bar", "hello foo", ...)) . + * </pre> * - * This is a way of using the full text index to filter instead of - * using regex. + * This is a way of using the full text index to filter instead of using regex. */ public class ASTSearchInSearchOptimizer extends AbstractJoinGroupOptimizer { - private static final Logger log = Logger.getLogger(ASTSearchInSearchOptimizer.class); +// private static final Logger log = Logger.getLogger(ASTSearchInSearchOptimizer.class); - static long time = 0; +// static private long time = 0; /** * Optimize the join group. @@ -81,7 +82,7 @@ protected void optimizeJoinGroup(final AST2BOpContext ctx, final StaticAnalysis sa, final IBindingSet[] bSets, final JoinGroupNode group) { - final long start = System.currentTimeMillis(); +// final long start = System.currentTimeMillis(); for (FilterNode node : group.getChildren(FilterNode.class)) { @@ -89,7 +90,7 @@ } - time += (System.currentTimeMillis() - start); +// time += (System.currentTimeMillis() - start); // System.err.println(time); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchOptimizer.java 2014-01-17 15:38:51 UTC (rev 7813) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTSearchOptimizer.java 2014-01-18 23:00:38 UTC (rev 7814) @@ -57,19 +57,18 @@ import com.bigdata.rdf.sparql.ast.VarNode; import com.bigdata.rdf.sparql.ast.optimizers.IASTOptimizer; import com.bigdata.rdf.sparql.ast.service.ServiceNode; -import com.bigdata.rdf.store.BD; import com.bigdata.rdf.store.BDS; /** - * Translate {@link BD#SEARCH} and related magic predicates into a + * Translate {@link BDS#SEARCH} and related magic predicates into a * {@link ServiceNode} which will invoke the bigdata search engine. * * <pre> * with { * select ?subj ?score * where { - * ?lit bd:search "foo" . - * ?lit bd:relevance ?score . + * ?lit bds:search "foo" . + * ?lit bds:relevance ?score . * ?subj ?p ?lit . * } * ORDER BY DESC(?score) @@ -88,7 +87,7 @@ /** * The known search URIs. * <p> - * Note: We can recognize anything in {@link BD#SEARCH_NAMESPACE}, but the + * Note: We can recognize anything in {@link BDS#SEARCH_NAMESPACE}, but the * predicate still has to be something that we know how to interpret. */ static final Set<URI> searchUris; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/store/BDS.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/store/BDS.java 2014-01-17 15:38:51 UTC (rev 7813) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/store/BDS.java 2014-01-18 23:00:38 UTC (rev 7814) @@ -103,8 +103,8 @@ * * select ?s ?relevance * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:relevance ?relevance . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:relevance ?relevance . * } * * </pre> @@ -131,8 +131,8 @@ * * select ?s ?rank * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:rank ?rank . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:rank ?rank . * } * * </pre> @@ -152,8 +152,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:maxRank "5"^^xsd:int . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:maxRank "5"^^xsd:int . * } * * </pre> @@ -183,8 +183,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:minRank "5"^^xsd:int . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:minRank "5"^^xsd:int . * } * * </pre> @@ -208,8 +208,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:minRelevance "0.5"^^xsd:double . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:minRelevance "0.5"^^xsd:double . * } * * </pre> @@ -232,8 +232,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:maxRelevance "0.9"^^xsd:double . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:maxRelevance "0.9"^^xsd:double . * } * * </pre> @@ -263,8 +263,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:matchAllTerms "true" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:matchAllTerms "true" . * } * * </pre> @@ -283,8 +283,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:matchExact "true" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:matchExact "true" . * } * * </pre> @@ -306,8 +306,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:matchRegex "regex to apply to ?s bindings" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:matchRegex "regex to apply to ?s bindings" . * } * * </pre> @@ -320,6 +320,22 @@ final String DEFAULT_MATCH_REGEX = null; /** + * + * <strong>Prefix matching is now indicated using a wildcard</strong> + * + * <pre> + * PREFIX bds: <http://www.bigdata.com/rdf/search#> + * + * SELECT ?subj ?label + * WHERE { + * ?label bds:search "mi*" . + * ?label bds:relevance ?cosine . + * ?subj ?p ?label . + * } + * </pre> + * + * <strong>The following approach is no longer supported. </strong> + * * Magic predicate used to query for free text search metadata to turn on * prefix matching. Prefix matching will match all full text index tokens * that begin with the specified token(s) (default @@ -331,16 +347,25 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:prefixMatch "true" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:prefixMatch "true" . * } * * </pre> * <p> * This will turn on prefix matching. + * + * @deprecated Prefix matching is now invoked using a wildcard. + * + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/803" > + * prefixMatch does not work in full text search </a> */ + @Deprecated final URI PREFIX_MATCH = new URIImpl(NAMESPACE + "prefixMatch"); - + + /** + * @deprecated This option is now invoked using a wildcard. + */ final boolean DEFAULT_PREFIX_MATCH = false; /** @@ -351,8 +376,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:subjectSearch "true" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:subjectSearch "true" . * } * * </pre> @@ -381,8 +406,8 @@ * * select ?s * where { - * ?s bd:search "scale-out RDF triplestore" . - * ?s bd:searchTimeout "5000" . + * ?s bds:search "scale-out RDF triplestore" . + * ?s bds:searchTimeout "5000" . * } * * </pre> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match.rq 2014-01-17 15:38:51 UTC (rev 7813) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match.rq 2014-01-18 23:00:38 UTC (rev 7814) @@ -1,15 +1,9 @@ # Search query. -PREFIX bd: <http://www.bigdata.com/rdf/search#> +PREFIX bds: <http://www.bigdata.com/rdf/search#> SELECT ?subj ?label - WITH { - SELECT ?subj ( ?lit as ?label ) - WHERE { - ?lit bd:search "mi*" . - ?lit bd:relevance ?cosine . - ?subj ?p ?lit . - } - } as %searchSet1 WHERE { - include %searchSet1 + ?label bds:search "mi*" . + ?label bds:relevance ?cosine . + ?subj ?p ?label . } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match2.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match2.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/search-prefix-match2.rq 2014-01-18 23:00:38 UTC (rev 7814) @@ -0,0 +1,15 @@ +# Search query. +PREFIX bds: <http://www.bigdata.com/rdf/search#> + +SELECT ?subj ?label + WITH { + SELECT ?subj ( ?lit as ?label ) + WHERE { + ?lit bds:search "mi*" . + ?lit bds:relevance ?cosine . + ?subj ?p ?lit . + } + } as %searchSet1 +WHERE { + include %searchSet1 +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/service/TestSearch.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/service/TestSearch.java 2014-01-17 15:38:51 UTC (rev 7813) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/service/TestSearch.java 2014-01-18 23:00:38 UTC (rev 7814) @@ -154,11 +154,60 @@ /** * Unit test for a prefix match ("mi*"). + * + * <pre> + * # Search query. + * PREFIX bds: <http://www.bigdata.com/rdf/search#> + * + * SELECT ?subj ?label + * WHERE { + * ?lit bds:search "mi*" . + * ?lit bds:relevance ?cosine . + * ?subj ?p ?label . + * } + * </pre> */ public void test_search_prefix_match() throws Exception { - new TestHelper("search-prefix-match").runTest(); + new TestHelper( + "search-prefix-match",// testURI + "search-prefix-match.rq",// query + "search-prefix-match.trig",//data + "search-prefix-match.srx" // expected results + ).runTest(); + + } + + /** + * Unit test for a prefix match ("mi*"). + * + * <pre> + * # Search query. + * PREFIX bds: <http://www.bigdata.com/rdf/search#> + * + * SELECT ?subj ?label + * WITH { + * SELECT ?subj ( ?lit as ?label ) + * WHERE { + * ?lit bds:search "mi*" . + * ?lit bds:relevance ?cosine . + * ?subj ?p ?lit . + * } + * } as %searchSet1 + * WHERE { + * include %searchSet1 + * } + * </pre> + */ + public void test_search_prefix_match2() throws Exception { + new TestHelper( + "search-prefix-match2",// testURI + "search-prefix-match2.rq",// query + "search-prefix-match.trig",//data + "search-prefix-match.srx" // expected results + ).runTest(); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |