mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
a0d5801661
commit
7c3ed5867e
|
@ -133,7 +133,7 @@ public class ExtendableQueryParser extends QueryParser {
|
||||||
final ParserExtension extension = this.extensions
|
final ParserExtension extension = this.extensions
|
||||||
.getExtension(splitExtensionField.cud);
|
.getExtension(splitExtensionField.cud);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
return extension.parse(new ExtensionQuery(splitExtensionField.cur,
|
return extension.parse(new ExtensionQuery(this, splitExtensionField.cur,
|
||||||
queryText));
|
queryText));
|
||||||
}
|
}
|
||||||
return super.getFieldQuery(field, queryText);
|
return super.getFieldQuery(field, queryText);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.apache.lucene.queryParser.ext;
|
package org.apache.lucene.queryParser.ext;
|
||||||
|
|
||||||
|
import org.apache.lucene.queryParser.QueryParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -29,6 +31,7 @@ public class ExtensionQuery {
|
||||||
|
|
||||||
private final String field;
|
private final String field;
|
||||||
private final String rawQueryString;
|
private final String rawQueryString;
|
||||||
|
private final QueryParser topLevelParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ExtensionQuery}
|
* Creates a new {@link ExtensionQuery}
|
||||||
|
@ -38,9 +41,10 @@ public class ExtensionQuery {
|
||||||
* @param rawQueryString
|
* @param rawQueryString
|
||||||
* the raw extension query string
|
* the raw extension query string
|
||||||
*/
|
*/
|
||||||
public ExtensionQuery(String field, String rawQueryString) {
|
public ExtensionQuery(QueryParser topLevelParser, String field, String rawQueryString) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.rawQueryString = rawQueryString;
|
this.rawQueryString = rawQueryString;
|
||||||
|
this.topLevelParser = topLevelParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,4 +64,12 @@ public class ExtensionQuery {
|
||||||
public String getRawQueryString() {
|
public String getRawQueryString() {
|
||||||
return rawQueryString;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue