|
Novell exteNd Director 5.0 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Query interface. Objects that implement this interface represent queries executed via the Search Service's Query Engine.
The following is an example of running a query:
// Instantiate a blank query object com.sssw.search.api.EbiQuery query = com.sssw.search.factory.EboFactory.getQuery(); // The query type will be "text" query.setQueryType(query.QUERY_TYPE_TEXT); // Specify the actual query query.setText("movies+science+fiction"); // Provide any field specifiers (want movie reviews whose genre is comedy) String fieldSpecList = "fnameDOCTYPENAME=*MovieReview*+fnameGenre=*Comedy*" String fieldBooleanExpr = "fnameDOCTYPENAME+AND+fnameGenre"; query.setFieldSpecList(fieldSpecList, fieldBooleanExpr); // Use the batch mode to paginate through results -- get the first 10 query.setBatchOptions(0, 10); // Narrow the scope by date query.setDateRange(Timestamp.valueOf("1999-03-05 12:00:00"), new java.util.Date()); // We want quick summaries generated query.setGenerateQuickSummary(true); // We want at most 100 results for this query query.setMaxNumResults(100); // We only want 70% and up relevance query.setRelevanceCut(70); // Sort results by date query.setSortByDate(true); // Sort results by relevance query.setSortByRelevance(true); // Get the query engine EbiQueryEngine qe = com.sssw.search.factory.EboFactory.getQueryEngine(); // Run the query Iterator iterResults = qe.runQuery(context, query, null, true).iterator(); // Process the results while (iterResults.hasNext()) { com.sssw.search.api.EbiQueryResult res = (com.sssw.search.api.EbiQueryResult)iterResults.next(); System.out.println(res); }
Field Summary | |
static int |
QUERY_TYPE_FUZZY
Fuzzy query type. |
static int |
QUERY_TYPE_GETALL
The "get all documents" query type. |
static int |
QUERY_TYPE_NAMESEARCH
The "name search" query type to search for proper names. |
static int |
QUERY_TYPE_SUGGEST
The "suggest similar documents" query type. |
static int |
QUERY_TYPE_TEXT
Basic text query type. |
Method Summary | |
boolean |
allSelected()
Tells whether all the document properties are selected. |
void |
clear()
Clears any information set into the query by the caller. |
void |
deselectAll()
Deselects all the properties that the caller previously selected. |
void |
fromXML(org.w3c.dom.Node xmlData)
Initializes this query object from XML data. |
int |
getBatchSize()
For batch queries, gets the chosen batch size. |
int |
getBatchStart()
For batch queries, gets the chosen batch start. |
Date |
getDateRangeEnd()
Gets the upper bracket (end) of the date range, if specified. |
Date |
getDateRangeStart()
Gets the lower bracket (start) of the date range, if specified. |
String[] |
getExclusions()
Gets the list of any exclusions, i.e. |
String |
getFieldBooleanExpr()
Gets the field Boolean expression, if any |
String |
getFieldSpecList()
Gets the field specifier list. |
int |
getMaxNumResults()
Gets the maximum number of results to be returned. |
int |
getQueryType()
Gets the query type. |
int |
getRelevanceCut()
Gets the relevance cut. |
Collection |
getSelects()
Get the list of selected document properties. |
String |
getText()
Gets the query text. |
EbiRepositoryDesc |
getThesaurus()
Gets the Thesaurus options set up for this Query object, if any. |
boolean |
isBatched()
Tells whether the query is being run in the batch mode, i.e. |
boolean |
isSelected(String propName)
Tells whether the specified property is selected. |
boolean |
isThesaurusQuery()
Tells whether this Query is marked to run as a thesaurus query. |
boolean |
mustExcludeSuggestDocs()
Tells whether the documents whose identifiers are specified in the query text are to be excluded from the query results. |
boolean |
mustGenerateQuickSummary()
Tells whether quick summaries are to be generated per each of the query results. |
boolean |
mustSortByDate()
Tells whether the query results are to be sorted by date. |
boolean |
mustSortByRelevance()
Tells whether the query results are to be sorted by relevance. |
boolean |
mustUseAbsWeight()
Tells whether relevance scores are to be returned per document as absolute weights rather than percentages. |
boolean |
mustUseExclusionsAsIDs()
Tells whether any specified exclusions should be treated as document IDs. |
boolean |
mustUseIDsForSuggest()
Tells whether the document identifiers supplied in the query text are to be treated as document IDs. |
boolean |
removeSelect(String propName)
Removes the specified property from the list of selected properties. |
void |
select(String propName)
Selects a specific property. |
void |
selectAll()
Selects all available document properties to be returned in the query results. |
void |
selectAlways(String propName)
Specifies that the given property is always to be selected. |
void |
setBatchOptions(int batchStart,
int batchSize)
Sets options for getting a batch ("pageful") of query results back instead of getting all the results back. |
void |
setDateRange(Date from,
Date to)
Sets the date range (optional). |
void |
setExclusions(String[] exclusions,
boolean useAsIDs)
Specifies any exclusions from the query results. |
void |
setFieldSpecList(String fieldSpecList,
String fieldBooleanExpr)
Sets the field specifier list. |
void |
setGenerateQuickSummary(boolean generate)
Specifies that quick summaries are to be generated per each of the query results. |
void |
setIsThesaurusQuery(boolean isThesaurusQuery)
Marks (or unmarks) this Query to be run as a thesaurus query. |
void |
setMaxNumResults(int maxNumResults)
Sets the maximum number of results to be returned. |
void |
setQueryType(int type)
Sets the query type. |
void |
setRelevanceCut(int relevanceCut)
Sets the relevance cut (results threshold, minimum similarity score) for query results. |
void |
setSortByDate(boolean doSortByDate)
Specifies whether the query results are to be sorted by date. |
void |
setSortByRelevance(boolean doSortByRelevance)
Specifies whether the query results are to be sorted by relevance. |
void |
setSuggestOptions(boolean useIDs,
boolean excludeSuggestDocs)
Sets options for a "suggest more" query ( QUERY_TYPE_SUGGEST ). |
void |
setText(String queryText)
Sets the query text. |
void |
setThesaurus(EbiRepositoryDesc thesaurus)
Sets up the Thesaurus options for this Query object. |
void |
setUseAbsWeight(boolean useAbsWeight)
Specifies that the relevance scores are to be returned per document as absolute weights rather than percentages. |
org.w3c.dom.Document |
toXML()
Returns an XML representation of the query object. |
Field Detail |
public static final int QUERY_TYPE_TEXT
// Instantiate a blank query object com.sssw.search.api.EbiQuery query = com.sssw.search.factory.EboFactory.getQuery(); // The query type will be "text" query.setQueryType(query.QUERY_TYPE_TEXT); query.setText("thriller+psychological");
public static final int QUERY_TYPE_FUZZY
// Instantiate a blank query object com.sssw.search.api.EbiQuery query = com.sssw.search.factory.EboFactory.getQuery(); // The query type will be "fuzzy" query.setQueryType(query.QUERY_TYPE_FUZZY); query.setText("film+noir");
public static final int QUERY_TYPE_GETALL
public static final int QUERY_TYPE_SUGGEST
// Instantiate a blank query object com.sssw.search.api.EbiQuery query = com.sssw.search.factory.EboFactory.getQuery(); // The query type will be "suggest more" query.setQueryType(query.QUERY_TYPE_SUGGEST); query.setSuggestOptions(false, true); query.setText("Arts/Movies/1999/The Matrix+Arts/Movies/1979/Alien");
public static final int QUERY_TYPE_NAMESEARCH
// Instantiate a blank query object com.sssw.search.api.EbiQuery query = com.sssw.search.factory.EboFactory.getQuery(); // The query type will be "namesearch" query.setQueryType(query.QUERY_TYPE_NAMESEARCH); query.setText("Jane+Fonda");
Method Detail |
public void setQueryType(int type)
type
- the query typeEbiQuery.getQueryType()
public int getQueryType()
EbiQuery.setQueryType(int)
public void setSuggestOptions(boolean useIDs, boolean excludeSuggestDocs)
QUERY_TYPE_SUGGEST
). Use this method for suggest
queries only.useIDs
- if true, then the document identifiers supplied in the
query text are to be treated as document IDs, otherwise as document
referencesexcludeSuggestDocs
- if true, then the documents whose identifiers
are specified in the query text are to be excluded from the query
resultspublic boolean mustUseIDsForSuggest()
EbiQuery.setSuggestOptions(boolean, boolean)
public boolean mustExcludeSuggestDocs()
public void setBatchOptions(int batchStart, int batchSize)
query.setText("silk+worm"); boolean done = false; int batchStart = 0; int batchSize = 10; // While there are unprocessed results while (!done) { // Set up the batch start and size query.setBatchOptions(batchStart, batchSize); // Get the next batchful Collection results = queryEngine.runQuery( context, query, repositories, true); // If no results, we're done if (results.isEmpty()) done = true; // Otherwise else { // Process this batchful printResults(results); // This must be the last batch if (results.size() < batchSize) done = true; // Go on to the next batch else batchStart += batchSize; } }
batch
- start the start of the batchbatchSize
- the batch sizeEbiQuery.getBatchStart()
,
EbiQuery.getBatchSize()
public int getBatchStart()
EbiQuery.getBatchSize()
,
EbiQuery.setBatchOptions(int, int)
public int getBatchSize()
EbiQuery.getBatchStart()
,
EbiQuery.setBatchOptions(int, int)
public boolean isBatched()
public void setThesaurus(EbiRepositoryDesc thesaurus)
query.setText("inhalation"); query.setIsThesaurusQuery(true); EbiRepositoryDesc thesaurus = com.sssw.search.factory.EboFactory.getRepositoryDesc( "141.155.166.181", 2000, 2001, "MyThesaurus"); query.setThesaurus(thesaurus); Collection results = queryEngine.runQuery( context, query, repositories, true);
thesaurus
- the Thesaurus descriptorEbiRepositoryDesc
,
EbiQuery.getThesaurus()
,
EbiQuery.setIsThesaurusQuery(boolean)
,
EbiQuery.isThesaurusQuery()
public EbiRepositoryDesc getThesaurus()
EbiRepositoryDesc
,
EbiQuery.setThesaurus(EbiRepositoryDesc)
,
EbiQuery.setIsThesaurusQuery(boolean)
,
EbiQuery.isThesaurusQuery()
public void setIsThesaurusQuery(boolean isThesaurusQuery)
isThesaurusQuery
- if true, marks this Query to be run as
a thesaurus querypublic boolean isThesaurusQuery()
public void setText(String queryText)
queryText
- the query text, e.g. "movie+science+fiction"public String getText()
public void setMaxNumResults(int maxNumResults)
maxNumResults
- the maximum number of results to be returnedpublic int getMaxNumResults()
public void setRelevanceCut(int relevanceCut)
relevanceCut
- the relevance cutEbiQuery.getRelevanceCut()
public int getRelevanceCut()
EbiQuery.setRelevanceCut(int)
public void setDateRange(Date from, Date to)
from
- the start of the date rangeto
- the end of the date rangeEbiQuery.getDateRangeStart()
,
EbiQuery.getDateRangeEnd()
public Date getDateRangeStart()
EbiQuery.getDateRangeEnd()
,
EbiQuery.setDateRange(Date, Date)
public Date getDateRangeEnd()
EbiQuery.getDateRangeStart()
,
EbiQuery.setDateRange(Date, Date)
public void setGenerateQuickSummary(boolean generate)
generate
- if true, do generate the quick summariespublic boolean mustGenerateQuickSummary()
public void setUseAbsWeight(boolean useAbsWeight)
useAbsWeight
- public boolean mustUseAbsWeight()
public void setSortByDate(boolean doSortByDate)
doSortByDate
- if true, the query results are to be sorted by datepublic boolean mustSortByDate()
public void setSortByRelevance(boolean doSortByRelevance)
doSortByRelevance
- if true, the query results are to be sorted by
relevancepublic boolean mustSortByRelevance()
public void setExclusions(String[] exclusions, boolean useAsIDs)
exclusions
- useAsIDs
- EbiQuery.mustUseExclusionsAsIDs()
,
EbiQuery.getExclusions()
public String[] getExclusions()
setExclusions
method)EbiQuery.setExclusions(String[], boolean)
,
EbiQuery.mustUseExclusionsAsIDs()
public boolean mustUseExclusionsAsIDs()
EbiQuery.setExclusions(String[], boolean)
,
EbiQuery.getExclusions()
public void setFieldSpecList(String fieldSpecList, String fieldBooleanExpr)
Example:
// Search for documents whose Title is like "Gold Rush" // and whose Genre is Comedy String fieldSpecList = "fnameTITLE=*Gold Rush*+fnameGenre=*Comedy*" String fieldBooleanExpr = "fnameTITLE+AND+fnameGenre"; query.setFieldSpecList(fieldSpecList, fieldBooleanExpr);
fieldSpecList
- the field specifier listfieldBooleanExpr
- the field Boolean expression (if more than one
field spec given in fieldSpecList
, defines a Boolean
expression for them)EbiQuery.getFieldSpecList()
,
EbiQuery.getFieldBooleanExpr()
public String getFieldSpecList()
EbiQuery.setFieldSpecList(String, String)
public String getFieldBooleanExpr()
EbiQuery.setFieldSpecList(String, String)
public void selectAll()
EbiQuery.deselectAll()
,
EbiQuery.allSelected()
,
EbiQuery.getSelects()
public void deselectAll()
EbiQuery.allSelected()
,
EbiQuery.getSelects()
,
EbiQuery.selectAll()
public boolean allSelected()
EbiQuery.selectAll()
,
EbiQuery.deselectAll()
,
EbiQuery.getSelects()
public Collection getSelects()
Collection
String's)EbiQuery.selectAll()
,
EbiQuery.deselectAll()
,
EbiQuery.allSelected()
public void selectAlways(String propName)
propName
- the property that is always to be selectedpublic void select(String propName)
propName
- the property to selectpublic boolean removeSelect(String propName)
propName
- the property namepublic boolean isSelected(String propName)
propName
- the property namepublic void clear()
public void fromXML(org.w3c.dom.Node xmlData)
xmlData
- The XML data to use.public org.w3c.dom.Document toXML()
|
Novell exteNd Director 5.0 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |