gov.ornl.csed.csiir.idr.kdd.dataservice.server.models
Class DataSetQueryRequest

java.lang.Object
  extended by gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.DataSetQueryRequest

public final class DataSetQueryRequest
extends java.lang.Object

The DataSetQueryRequest class represents a query to be submitted to the data service. Boolean queries that search across all of a data set's fields may be constructed, as well as, boolean queries that target specific fields.

A query that searches across all of a data set's fields that would represent this query '((("bin laden" AND Usama) OR ("bin laden" AND Osama)) AND NOT mohamed)' could be built using the following code:

 QueryNode frag1 = QueryNode.createAndNode(
 	QueryNode.createKeywordNode("bin laden"),
	QueryNode.createKeywordNode("Usama"));
			
 QueryNode frag2 = QueryNode.createAndNode(
	QueryNode.createKeywordNode("bin laden"),
	QueryNode.createKeywordNode("Osama"));
					
 QueryNode frag3 = QueryNode.createOrNode(
	frag1, 
	frag2);
					
 QueryNode frag4 = QueryNode.createNotNode(
	QueryNode.createKeywordNode("mohamed"));
					
 QueryNode query = QueryNode.createAndNode(
	frag3, 
	frag4);

 DataSetQueryRequest dataSetQueryRequest = new DataSetQueryRequest(query);
 
 

To constrain a keyword value so that is it compared only to a specific field, create the keyword node as follows:

 QueryNode.createKeywordNode("fieldName", "keyword");
 
 


Nested Class Summary
static class DataSetQueryRequest.QueryNode
          The QueryNode class represents a node of a boolean query.
 
Constructor Summary
DataSetQueryRequest()
           
DataSetQueryRequest(DataSetQueryRequest.QueryNode query)
           
 
Method Summary
 void addReturnField(java.lang.String field)
          Add a field to the list of field values to retrieve.
 boolean equals(java.lang.Object obj)
           
 long getMaxRecords()
          Retrieve the maximum requested number of records.
 java.lang.String getQueryId()
          Retrieve the unique identifier associated with this query
 java.util.Queue<java.lang.String> getQueue()
          Retrieve the query in queue form.
 java.util.List<java.lang.String> getReturnFields()
          Retrieve the list of field values to be retrieved.
 boolean getReturnScore()
          Retrieve the value of the flag for returning the Lucene score.
 int hashCode()
           
 void removeReturnField(java.lang.String field)
          Remove a field from the list of field values to retrieve.
 void setMaxRecords(long maxRecords)
          Set the maximum records to retrieve.
 void setQuery(DataSetQueryRequest.QueryNode query)
          Set the query associated with this request.
 void setQueryId(java.lang.String queryId)
          Set the unique identifier associated with this query.
 void setQueue(java.util.Queue<java.lang.String> queue)
          Set the query in queue form.
 void setReturnFields(java.util.List<java.lang.String> returnFields)
          Set the list of field values to be retrieved.
 void setReturnScore(boolean getScore)
          Add the score field to the field values retrieved.
 java.lang.String toQueryString(java.util.Map<java.lang.String,java.lang.String> searchFields)
          Converts the query to an appropriate string form given the supplied search field map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataSetQueryRequest

public DataSetQueryRequest()

DataSetQueryRequest

public DataSetQueryRequest(DataSetQueryRequest.QueryNode query)
Method Detail

getQueryId

public java.lang.String getQueryId()
Retrieve the unique identifier associated with this query

Returns:
the unique query ID

setQueryId

public void setQueryId(java.lang.String queryId)
Set the unique identifier associated with this query. Used for serialization.

Parameters:
queryId - the unique query ID

setQuery

public void setQuery(DataSetQueryRequest.QueryNode query)
Set the query associated with this request.

Parameters:
query - the query node

getQueue

public java.util.Queue<java.lang.String> getQueue()
Retrieve the query in queue form. For serialization only.

Returns:
the query in queue form

setQueue

public void setQueue(java.util.Queue<java.lang.String> queue)
Set the query in queue form. For serialization only.

Parameters:
queue - the query in queue form

toQueryString

public java.lang.String toQueryString(java.util.Map<java.lang.String,java.lang.String> searchFields)
                               throws KDDDataServiceException
Converts the query to an appropriate string form given the supplied search field map.

Parameters:
searchFields - a map of search fields to their field type
Returns:
the query string
Throws:
KDDDataServiceException

getMaxRecords

public long getMaxRecords()
Retrieve the maximum requested number of records. The default (0) is to retrieve all records matching the query.

Returns:
the max records value

setMaxRecords

public void setMaxRecords(long maxRecords)
Set the maximum records to retrieve. The default (0) is to retrieve all records matching the query.

Parameters:
maxRecords - the maximum number of records to retrieve

addReturnField

public void addReturnField(java.lang.String field)
Add a field to the list of field values to retrieve. The default is to retrieve all available field values.

Parameters:
field - the field name

removeReturnField

public void removeReturnField(java.lang.String field)
Remove a field from the list of field values to retrieve. The default is to retrieve all available field values.

Parameters:
field - the field name

getReturnFields

public java.util.List<java.lang.String> getReturnFields()
Retrieve the list of field values to be retrieved. The default is to retrieve all available field values.

Returns:
the list of field values to be returned

setReturnFields

public void setReturnFields(java.util.List<java.lang.String> returnFields)
Set the list of field values to be retrieved. The default is to retrieve all available field values.

Parameters:
returnFields - the list of field names

setReturnScore

public void setReturnScore(boolean getScore)
Add the score field to the field values retrieved. The default is to retrieve the Lucene score field.

Parameters:
getScore - the boolean to retrieve the Lucene score

getReturnScore

public boolean getReturnScore()
Retrieve the value of the flag for returning the Lucene score.

Returns:
true if the score field will be retrieved, otherwise false

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object