public final class DDSQueryAction
extends org.apache.struts.action.Action
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ENCODED_FIELDS
A list of all fields that are indexed in encoded form via SimpleLuceneIndex.encodeToTerm()
|
static java.lang.String[][] |
FIELD_ALIASES
A list of aliases that map user-typed field names to the field name that exists in the index.
|
static int |
OPERATOR_AND
Indicates use of the AND boolean operator in the
getBooleanQuery(String[] terms, int operator,
boolean useStemming) method. |
static int |
OPERATOR_OR
Indicates use of the OR boolean operator in the
getBooleanQuery(String[] terms, int operator,
boolean useStemming) method. |
static java.lang.String[] |
SEARCH_TYPE_NAMES
Identifiers that get printed in the query/search logs
|
static int |
SEARCHTYPE_DDSWS_SEARCH
Indicates web service search by client using general search request
|
static int |
SEARCHTYPE_DDSWS_USER_SEARCH
Indicates web service search by client using user search request
|
static int |
SEARCHTYPE_GENERAL_RSS
Indicates an RSS general request
|
static int |
SEARCHTYPE_HISTOGRAM
Indicates histogram search by user
|
static int |
SEARCHTYPE_JSHTML_SEARCH
Indicates a JSHTML service search
|
static int |
SEARCHTYPE_ODL_SEARCH
Indicates web service search by client using the ODL request
|
static int |
SEARCHTYPE_SEARCH
Indicates textual search by user
|
static int |
SEARCHTYPE_WHATSNEW
Indicates whats new search by user
|
static int |
SEARCHTYPE_WHATSNEW_RSS
Indicates an RSS whats new request
|
Constructor and Description |
---|
DDSQueryAction() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addConstraintToQuery(java.lang.String query,
java.lang.String constraintQuery)
Adds a feature to the ConstraintToQuery attribute of the DDSQueryAction class
|
static DDSStandardSearchResult |
ddsStandardQuery(javax.servlet.http.HttpServletRequest request,
java.lang.String additionalQueryOrConstraint,
RepositoryManager rm,
MetadataVocab vocab,
javax.servlet.ServletContext context,
int searchType)
Performs textual and field-based searches limited to discoverable items only and using pre-defined search
logic.
|
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Processes the specified HTTP request and creates the corresponding HTTP response by forwarding to a JSP
that will create it.
|
static java.lang.StringBuffer |
formatEncodedFields(java.lang.String q)
Encodes a query string such that each term that is part of a field that has been encoded in the index
using
SimpleLuceneIndex .encodeToTerm() is replaced with the encoded form for
searching. |
static java.lang.String |
formatFieldsInQuery(java.lang.String q)
Formats the fields/terms in the query string by replacing the aliased field names and encoding terms that
are in fields that have been indexed encoded.
|
static java.lang.String |
getBooleanQuery(java.lang.String[] terms,
int operator,
boolean useStemming)
Creates a boolean query string for use in the standard Lucene query parser.
|
static java.lang.String |
getCollectionQueryTerm(java.lang.String ky)
Gets the Lucene query string necessary to pull out records for a given collection.
|
static org.apache.lucene.search.Query |
getGeospatialQuery(javax.servlet.http.HttpServletRequest request)
Generates a geospatial bounding box Lucene Query from the necessary parameteres in an http request, which
are geoPredicate, geoBBNorth, geoBBWest, geoBBEast, geoBBSouth.
|
static java.util.HashMap |
getStopWordMap()
Gets the stopWordMap attribute of the DDSQueryAction class
|
static java.lang.String |
getVocabParamsQueryString(javax.servlet.http.HttpServletRequest request,
MetadataVocab vocab,
java.util.HashMap docReaderAttributes)
Gets a query that limits a search to vocab-managed fields such as gradeRange (gr), resourceType (re),
subject (su), contentStandard (cs) and collection (ky).
|
static org.apache.lucene.search.Filter |
getWhatsNewDateFilter(java.lang.String wnfrom,
java.lang.String wnto)
Gets the whatsNewDateFilter attribute of the DDSQueryAction class
|
org.apache.struts.action.ActionForward |
handleMetadataSearchRequest(org.apache.struts.action.ActionMapping mapping,
DDSQueryForm queryForm,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
RepositoryManager rm)
Handle a request to search over metadata collections and forwared to the appropriate jsp page to render
the response.
|
static boolean |
logQuery(java.lang.String query,
javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpServletRequest request,
int statusCode,
int contentLen,
int numSearchResults,
int totalRecords,
int rank,
int searchType)
This method must be called at just after the user's query has been processed by Lucene.
|
static java.lang.String |
replaceAliasedFieldNames(java.lang.String q)
Substitutues the searchable field names for the common field names that user's may use in their query
string.
|
static void |
setDebug(boolean isDebugOutput)
Sets the debug attribute of the DDSQueryAction class
|
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
public static final int OPERATOR_AND
getBooleanQuery(String[] terms, int operator,
boolean useStemming)
method.public static final int OPERATOR_OR
getBooleanQuery(String[] terms, int operator,
boolean useStemming)
method.public static final int SEARCHTYPE_SEARCH
public static final int SEARCHTYPE_HISTOGRAM
public static final int SEARCHTYPE_WHATSNEW
public static final int SEARCHTYPE_DDSWS_USER_SEARCH
public static final int SEARCHTYPE_DDSWS_SEARCH
public static final int SEARCHTYPE_ODL_SEARCH
public static final int SEARCHTYPE_GENERAL_RSS
public static final int SEARCHTYPE_WHATSNEW_RSS
public static final int SEARCHTYPE_JSHTML_SEARCH
public static final java.lang.String[] SEARCH_TYPE_NAMES
public static final java.lang.String[] ENCODED_FIELDS
public static final java.lang.String[][] FIELD_ALIASES
public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
SimpleLuceneIndex
must be available to this class via
a ServletContext attribute under the key "index." Returns an ActionForward
instance that maps to the Struts forwarding name "simple.query,"
which must be configured in struts-config.xml to forward to the JSP page that will handle the request.execute
in class org.apache.struts.action.Action
mapping
- The ActionMapping used to select this instancerequest
- The HTTP request we are processingresponse
- The HTTP response we are creatingform
- The ActionForm for the given pagejava.io.IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet exception occurspublic org.apache.struts.action.ActionForward handleMetadataSearchRequest(org.apache.struts.action.ActionMapping mapping, DDSQueryForm queryForm, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, RepositoryManager rm) throws java.io.IOException, javax.servlet.ServletException
mapping
- The ActionMapping used to select this instancerequest
- The HTTP request we are processingresponse
- The HTTP response we are creatingrm
- queryForm
- java.io.IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet exception occurspublic static DDSStandardSearchResult ddsStandardQuery(javax.servlet.http.HttpServletRequest request, java.lang.String additionalQueryOrConstraint, RepositoryManager rm, MetadataVocab vocab, javax.servlet.ServletContext context, int searchType)
request
- The HTTP requestrm
- The RepositoryManagervocab
- The MetadataVocabcontext
- The ServletContextsearchType
- The searchType that gets loggedadditionalQueryOrConstraint
- If the q parameter is empty, this value will be used as the search
query, if q is not empty this value will be ANDed with itpublic static final java.lang.String addConstraintToQuery(java.lang.String query, java.lang.String constraintQuery)
query
- The feature to be added to the ConstraintToQuery attributeconstraintQuery
- The feature to be added to the ConstraintToQuery attributepublic static org.apache.lucene.search.Query getGeospatialQuery(javax.servlet.http.HttpServletRequest request) throws java.lang.Exception
request
- An http request that may contain geospatial parametersjava.lang.Exception
- If there is an error with one or more of the geospatial parameterspublic static final java.lang.String getVocabParamsQueryString(javax.servlet.http.HttpServletRequest request, MetadataVocab vocab, java.util.HashMap docReaderAttributes)
request
- The HTTP requestvocab
- The metadata vocab useddocReaderAttributes
- The doc reader attributespublic static final org.apache.lucene.search.Filter getWhatsNewDateFilter(java.lang.String wnfrom, java.lang.String wnto) throws java.text.ParseException
wnfrom
- The from datewnto
- The to datejava.text.ParseException
- If error parsingpublic static java.lang.String getCollectionQueryTerm(java.lang.String ky)
ky
- The vocab key, for example 06public static java.util.HashMap getStopWordMap()
public static final java.lang.String formatFieldsInQuery(java.lang.String q)
q
- The raw query by userpublic static final java.lang.StringBuffer formatEncodedFields(java.lang.String q)
SimpleLuceneIndex
.encodeToTerm() is replaced with the encoded form for
searching. May be used in conjuction with replaceAliasedFieldNames(String)
.
Examples:
'id:DLESE-000-000-000-001' becomes 'id:dlesex45000x45000x45000x45001'
'ocean AND urlenc:(http://*.noaa.gov* OR http://*.nasa.gov*)' becomes 'ocean AND
urlenc:(httpx58x47x47*x46noaax46gov* OR httpx58x47x47*x46nasax46gov*)'
q
- A query stringpublic static final java.lang.String replaceAliasedFieldNames(java.lang.String q)
formatEncodedFields(String)
.
Examples:
'url:http://*.noaa.gov*' becomes 'urlenc:http://*.noaa.gov*'
q
- A query from a userpublic static final java.lang.String getBooleanQuery(java.lang.String[] terms, int operator, boolean useStemming)
terms
- The terms used in the query.operator
- The operator to use (AND|OR).useStemming
- True to stem the tersm, false to leave unchanged.public static final boolean logQuery(java.lang.String query, javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, int statusCode, int contentLen, int numSearchResults, int totalRecords, int rank, int searchType)
query
- The text query entered by the user or submitted by the web service client, or
null if none was submitted with the requeststatusCode
- The http status codecontentLen
- The length of the data returned, in bytesnumSearchResults
- The number of search results returned by the querytotalRecords
- The total number of records in the system at the time of the queryrank
- The rank of the item(s) retunred on the page. If this is a results page, then
this is rank of the first item on the page.servletContext
- The servletContextrequest
- The HTTP requestsearchType
- The search type (search, histogram, what's new, ws-uql, ws-lql, etc)public static void setDebug(boolean isDebugOutput)
isDebugOutput
- The new debug value