|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.greenstone.fedora.services.GSearchConnection
public class GSearchConnection
Class GSearchConnection connects to FedoraGSearch's web services. FedorGSearch offers indexing and full-text search functionality for Fedora repositories. Its search web service (method gFindObjects) returns the response of a search as XML. GSearchConnection offers more convenient methods that extract just the parts of search results that FedoraGS3Connection needs and returns that.
Field Summary | |
---|---|
protected javax.xml.parsers.DocumentBuilder |
builder
A DocumentBuilder object used to construct and parse XML |
protected org.apache.axis.client.Call |
call
The Call object used to connect to the FedoraGSearch web services |
protected static java.lang.String |
DC_TITLE_FIELD
|
protected static java.lang.String |
FIELD
|
protected static java.lang.String |
FULLTEXT_FIELD
|
protected static java.lang.String |
G_FIND_OBJECTS
The names of the methods we use of Fedora Generic Search's web services are declared here as static final Strings. |
protected static java.lang.String |
HIT_TOTAL
|
java.lang.String |
indexName
The name of the Index wherein FedoraGSearch has indexed all the GS3 docs. |
protected static java.lang.String |
NAME
|
protected static java.lang.String |
NAMESPACE_URI
|
protected static java.lang.String |
OBJECT
|
protected static java.lang.String |
PID
|
protected javax.xml.namespace.QName |
portName
The portName object used when connecting to FedoraGSearch's web services |
protected org.apache.axis.client.Service |
service
The Service object used to connect to the FedoraGSearch web services |
protected static java.lang.String |
SERVICE_NAME
|
protected static java.lang.String |
SPACE
separator used internally to separate values of a search field |
Fields inherited from interface org.greenstone.fedora.services.FedoraToGS3Interface.Constants |
---|
ALL_FIELDS, ALL_TITLES, ASSOCFILEPREFIX, COMMA, DOC_TITLES, FIELDNAME_ATT, FULLTEXT, GS3FilePathMacro, MAXDOCS, NUM_DOCS_MATCHED, OCCURS_ATT, QUERY, SIMPLEFIELD_ATT |
Constructor Summary | |
---|---|
GSearchConnection(java.lang.String wsdlFileLocation,
java.lang.String indexName)
Constructor that takes a String representing the url of the WSDL file for FedoraGSearch's web services, and tries to establish a connection to those web services. |
Method Summary | |
---|---|
protected java.lang.String |
formatSearchTermsInField(java.lang.String field,
java.lang.String fieldName)
Each field is a comma separated list of terms that may be either a word OR a phrase. |
java.lang.String[] |
getPIDsFromSearchResult(java.lang.String collectionName,
java.lang.String searchResult)
Call this method with the return value of calling search(). |
protected java.lang.String |
gFindObjects(java.lang.String searchFieldedTerms,
java.lang.String sort,
int hitPageStart,
int hitPageSize,
int snippetsMax,
int fieldMaxLength,
java.lang.String indexName,
java.lang.String resultPageXslt)
Method to invoke gfindObjects operation of Fedora Generic Search web services. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
search(java.util.Map fieldsToSearchTerms,
int hitPageStart,
int hitPageSize)
FedoraGSearch accepts a query of the form: <"cyclone val" "Gender Inequalities" ds.fulltext:"cyclone val"
ds.fulltext:"worst storm">
where the first two phrases are searched for in all indexed fields,
(in this case dc.title and ds.fulltext), while the last two are
searched for in the ds.fulltext field. |
java.lang.String |
search(java.lang.String fieldedSearchTerms,
int hitPageStart,
int hitPageSize,
int snippetsMax)
Uses FedoraGSearch to perform a search where the query is embedded in fieldedSearchTerms, which not only provides the terms to search on, but also the fields to search the (various) given terms in. |
java.lang.String |
search(java.lang.String searchFieldName,
java.lang.String searchTerm,
int hitPageStart,
int hitPageSize,
int snippetsMax)
Method that performs a search for the given searchTerm inside the given indexed field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.String NAMESPACE_URI
protected static java.lang.String SERVICE_NAME
protected static final java.lang.String G_FIND_OBJECTS
protected static final java.lang.String PID
protected static final java.lang.String HIT_TOTAL
protected static final java.lang.String OBJECT
protected static final java.lang.String FIELD
protected static final java.lang.String NAME
protected static final java.lang.String DC_TITLE_FIELD
protected static final java.lang.String FULLTEXT_FIELD
protected static final java.lang.String SPACE
public final java.lang.String indexName
protected final org.apache.axis.client.Service service
protected final org.apache.axis.client.Call call
protected final javax.xml.namespace.QName portName
protected final javax.xml.parsers.DocumentBuilder builder
Constructor Detail |
---|
public GSearchConnection(java.lang.String wsdlFileLocation, java.lang.String indexName) throws java.net.MalformedURLException, javax.xml.rpc.ServiceException, javax.xml.parsers.ParserConfigurationException
wsdlFileLocation
- is a String representing the url of the WSDL fileindexName
- is the name of the index that Fedora Generic Search
should work with (the index wherein the indexed GS3 documents have been
placed).
java.net.MalformedURLException
javax.xml.rpc.ServiceException
javax.xml.parsers.ParserConfigurationException
Method Detail |
---|
protected java.lang.String gFindObjects(java.lang.String searchFieldedTerms, java.lang.String sort, int hitPageStart, int hitPageSize, int snippetsMax, int fieldMaxLength, java.lang.String indexName, java.lang.String resultPageXslt) throws java.lang.Exception
java.lang.Exception
public java.lang.String search(java.lang.String searchFieldName, java.lang.String searchTerm, int hitPageStart, int hitPageSize, int snippetsMax) throws java.lang.Exception
searchFieldName
- is the name of the indexed field within which the
given searchTerm is to be searched for.searchTerm
- is the term to be searched for.hitPageStart
- is the page of search results to start returning.hitPageSize
- is the number of search result pages to return,
starting from hitPageStart.snippetsMax
- is the maximum number of separate snippets containing
the searchTerm that are to be returned. (snippetsMax or a fewer number of
occurrences of the word in the text will be returned)
java.lang.Exception
public java.lang.String search(java.util.Map fieldsToSearchTerms, int hitPageStart, int hitPageSize) throws java.lang.Exception
<"cyclone val" "Gender Inequalities" ds.fulltext:"cyclone val"
ds.fulltext:"worst storm">
where the first two phrases are searched for in all indexed fields,
(in this case dc.title and ds.fulltext), while the last two are
searched for in the ds.fulltext field.
Another example:
<gender dc.title:interview ds.fulltext:"cyclone val">
titles and fulltexts are searched for "gender", while title index
is searched for "interview" and fulltexts are searched for the phrase
"cyclone val"
fieldsToSearchTerms
- is a Hashmap of searchfields and
associated search terms (words or phrases). The terms are in a
comma-separated list. fieldsToSearchTerms is a Hashmap of
(Searchfields, associated-searchTerms) pairs. It can contain 3
searchfields: allfields, titles, text. The value for each is a
comma-separated list of search terms in that field.
Internally the field names get converted to what FedoraGSearch's
gfindObjects understands: titles becomes dc.title:, text becomes
ds.fulltext and allfields becomes nothing.hitPageStart
- is the page of search results to start returning.hitPageSize
- is the number of search result pages to return,
starting from hitPageStart.
java.lang.Exception
protected java.lang.String formatSearchTermsInField(java.lang.String field, java.lang.String fieldName)
dc.title:"a phrase" word dc.fulltext: "cyclone val" (ALL_FIELDS) interview genderThis is required to facilitate fielded searching with fedoraGSearch.
field
- is a comma separated list of search terms (corresponding
to one fieldName) to be reorganisedfieldName
- is the name of the field to prepend to the reorganised
field value. FieldName ALL_FIELDS is ignored.
public java.lang.String search(java.lang.String fieldedSearchTerms, int hitPageStart, int hitPageSize, int snippetsMax) throws java.lang.Exception
fieldedSearchTerms
- is the String specifying all the search terms
with their fields (or no field if it should search for the terms in
all fields). The terms with no associated search-fields should come first.
Search terms may be in quotes.snippetsMax
- is the maximum number of separate snippets containing
the searchTerm (snippetsMax number of occurrences of the word in the text)
returned.hitPageStart
- is the page of search results to start returning.hitPageSize
- is the number of search result pages to return,
starting from hitPageStart.
java.lang.Exception
public java.lang.String[] getPIDsFromSearchResult(java.lang.String collectionName, java.lang.String searchResult) throws java.lang.Exception
collectionName
- is the name of the collection to restrict the
search results by. If it's "", then results from all collections are
returned. Generally, don't want to pass "", because, theoretically,
all indexed collections in the repository could be considered and
not all of them may be Greenstone collections. If all Greenstone
collections should be searched for, pass "greenstone" as the
collection name instead.searchResult
- is the Fedora Generic Search XML response returned
from performing a gfindObjects() operations.
java.lang.Exception
public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |