From 7c3ed5867ee817a6089bf8250fffd349fb8c2670 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 28 Dec 2009 14:27:14 +0000 Subject: [PATCH] LUCENE-2162: Allow ExtendableQueryParser extensions accessing the toplevel parser and its properties git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@894180 13f79535-47bb-0310-9956-ffa450edef68 --- .../queryParser/ext/ExtendableQueryParser.java | 2 +- .../lucene/queryParser/ext/ExtensionQuery.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java b/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java index 680e35d2271..1533d11d5bd 100644 --- a/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java +++ b/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java @@ -133,7 +133,7 @@ public class ExtendableQueryParser extends QueryParser { final ParserExtension extension = this.extensions .getExtension(splitExtensionField.cud); if (extension != null) { - return extension.parse(new ExtensionQuery(splitExtensionField.cur, + return extension.parse(new ExtensionQuery(this, splitExtensionField.cur, queryText)); } return super.getFieldQuery(field, queryText); diff --git a/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java b/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java index ae68682915d..f84faf85b83 100644 --- a/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java +++ b/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java @@ -1,5 +1,7 @@ package org.apache.lucene.queryParser.ext; +import org.apache.lucene.queryParser.QueryParser; + /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,6 +31,7 @@ public class ExtensionQuery { private final String field; private final String rawQueryString; + private final QueryParser topLevelParser; /** * Creates a new {@link ExtensionQuery} @@ -38,9 +41,10 @@ public class ExtensionQuery { * @param rawQueryString * the raw extension query string */ - public ExtensionQuery(String field, String rawQueryString) { + public ExtensionQuery(QueryParser topLevelParser, String field, String rawQueryString) { this.field = field; this.rawQueryString = rawQueryString; + this.topLevelParser = topLevelParser; } /** @@ -60,4 +64,12 @@ public class ExtensionQuery { public String getRawQueryString() { return rawQueryString; } + + /** + * Returns the top level parser which created this {@link ExtensionQuery} + * @return the top level parser which created this {@link ExtensionQuery} + */ + public QueryParser getTopLevelParser() { + return topLevelParser; + } }