public class VirtualSearchFieldMapper
extends java.lang.Object
XMLQueryParser
class. See sample XML file . Mappings
can also be added or removed directly using the API. The API returns Queries for the given field/term
pairs, and a FieldExpansionQueryParser
may be used to apply the
field/term mappings when supplied in regular Lucene query strings.FieldExpansionQueryParser
,
XMLQueryParser
Constructor and Description |
---|
VirtualSearchFieldMapper(org.apache.lucene.queryParser.QueryParser parser)
Constructor for the VirtualSearchFieldMapper object
|
Modifier and Type | Method and Description |
---|---|
void |
addVirtualFieldConfiguration(java.io.File xmlConfigFile)
Adds all virtual field/term query definitions (virtualSearchField elements) contained in the given XML
configuration file, replacing any previous definitions.
|
void |
addVirtualFieldConfiguration(java.lang.String xmlConfig)
Adds all virtual field/term query definitions (virtualSearchField elements) contained in the given XML
configuration String, replacing any previous definitions.
|
void |
addVirtualFieldConfiguration(java.net.URL xmlConfig)
Adds all virtual field/term query definitions (virtualSearchField elements) contained in the given XML
configuration file, replacing any previous definitions.
|
void |
clear()
Clears all field/term definitions that are defined.
|
boolean |
getIsTermConfiguredForField(java.lang.String virtualField,
java.lang.String virtualTerm)
Determines whether the given virtual term is configured for the given field.
|
int |
getNumTermsConfiguredForField(java.lang.String virtualField)
Gets the number of virtual terms configured for a given virtual field.
|
org.apache.lucene.search.Query |
getQuery(java.lang.String virtualField,
java.lang.String virtualTerm)
Gets the Lucene Query that is defined for the given virtual field/term pair, or null if none avaialable.
|
java.lang.String |
getQueryString(java.lang.String virtualField,
java.lang.String virtualTerm)
Gets the Lucene Query as a String for the given virtual field and term, or null if not avaialable.
|
java.lang.String[] |
getVirtualFields()
Gets the virtual fields that are defined.
|
java.lang.String[] |
getVirtualTerms(java.lang.String field)
Gets the virtual terms that are defined for the given field, or null.
|
boolean |
remove(java.lang.String virtualField)
Removes all term definitions that are defined for the given field.
|
boolean |
remove(java.lang.String virtualField,
java.lang.String virtualTerm)
Removes the definition that is defined for the given field and term.
|
void |
setQuery(java.lang.String virtualField,
java.lang.String virtualTerm,
org.apache.lucene.search.Query query)
Sets the Query assigned for the given field and term, overwriting any previous definition.
|
void |
setQuery(java.lang.String virtualField,
java.lang.String virtualTerm,
java.lang.String query)
Sets the Query assigned for the given field and term, overwriting any previous definition.
|
java.lang.String |
toString()
Outputs a String representation of the fields/terms/queries that are defined in this
VirtulSearchFieldMapper.
|
public VirtualSearchFieldMapper(org.apache.lucene.queryParser.QueryParser parser)
parser
- The QueryParser used to parse Lucene queries that are defined in the configuration filepublic org.apache.lucene.search.Query getQuery(java.lang.String virtualField, java.lang.String virtualTerm)
virtualField
- The virtual search fieldvirtualTerm
- The virtual search termpublic java.lang.String getQueryString(java.lang.String virtualField, java.lang.String virtualTerm)
virtualField
- The virtual search fieldvirtualTerm
- The virtual search termpublic int getNumTermsConfiguredForField(java.lang.String virtualField)
virtualField
- The virtual search fieldpublic boolean getIsTermConfiguredForField(java.lang.String virtualField, java.lang.String virtualTerm)
virtualField
- The virtual search fieldvirtualTerm
- The virtual search termpublic void setQuery(java.lang.String virtualField, java.lang.String virtualTerm, org.apache.lucene.search.Query query)
virtualField
- The fieldvirtualTerm
- The termquery
- The new Query value for this field/termpublic void setQuery(java.lang.String virtualField, java.lang.String virtualTerm, java.lang.String query) throws org.apache.lucene.queryParser.ParseException
QueryParser
Object that was passed into the constructor.virtualField
- The fieldvirtualTerm
- The termquery
- The new Query value for this field/termorg.apache.lucene.queryParser.ParseException
- If error parsing the query Stringpublic boolean remove(java.lang.String virtualField, java.lang.String virtualTerm)
getQuery(java.lang.String, java.lang.String)
or getQueryString(java.lang.String, java.lang.String)
for this field/term pair will return null.virtualField
- The fieldvirtualTerm
- The termpublic boolean remove(java.lang.String virtualField)
getQuery(java.lang.String, java.lang.String)
or getQueryString(java.lang.String, java.lang.String)
will return null for all references to this field.virtualField
- The field to removepublic void clear()
getQuery(java.lang.String, java.lang.String)
or getQueryString(java.lang.String, java.lang.String)
will return null for all calls.public java.lang.String[] getVirtualFields()
public java.lang.String[] getVirtualTerms(java.lang.String field)
field
- The fieldpublic void addVirtualFieldConfiguration(java.lang.String xmlConfig) throws java.lang.Exception
xmlConfig
- The VirtualSearchFieldMapper configuration XML stringjava.lang.Exception
- If error parsing the Stringpublic void addVirtualFieldConfiguration(java.io.File xmlConfigFile) throws java.lang.Exception
xmlConfigFile
- The VirtualSearchFieldMapper configuration XML filejava.lang.Exception
- If error parsing or reading the filepublic void addVirtualFieldConfiguration(java.net.URL xmlConfig) throws java.lang.Exception
xmlConfig
- The URL to the VirtualSearchFieldMapper configuration XML filejava.lang.Exception
- If error parsing or reading the urlpublic java.lang.String toString()
toString
in class java.lang.Object