You are here

You are here

Find Document By Attributes, Name or Content

A search can be done on a document name, description and attributes.

The same parameters that are available through the SpringCM user interface search are available in this method. This method will return multiple results if several documents match the search criteria.  Whether single or multiple results are found an SCMDocument array is always returned from this call.

The search API call allows developers to build custom search widgets that can be used as “views” into documents in SpringCM.  Generally, the capabilities of Search via the API are the same as what is provided by the SpringCM advanced search screen.  SpringCM recommends the newer DocumentPagedSearch method be used over the DocumentSearch method that does not allow paging and can be slower.

With either method, an SCMSearchDocument document is used to describe the parameters of the search.  The following describes the DocumentPagedSearch method and SCMSearchDocument object.

DocumentPagedSearch

Inputs
  • token – Authentication token used in all SOAP calls
  • search – An instance of an SCMSearchDocument that defines the search to run
  • loadExtendedMetadata – Whether metadata on the folder or document is loaded, should generally return false if the metadata is not needed for improve performance.
Output

The return value is an SCMSearchResult with 5 properties:

  • DocResults – An array of documents returned by the search
  • FolderResults – An array of folders returned by the search
  • NativeHitCount – Overall number of hits on the query
  • QueriedMaxHits – Current max hit index
  • ThereMayBeMoreHits – Specifies if there are more hits

SCMSearchDocument Object

  • AtLeastOneWord – Searches full text for at least one word in a list of words
  • Body – Searches full text
  • Description – Searches description
  • EndDate – Used in conjunction with StartDate to filter on modified dates
  • Extensions – List of file extensions on which to filter
  • InAnyAttributeField – Searches all attribute fields
  • LimitFolderId – Folder id to which search can be limited
  • LimitIncludeSubfolders – If LimitFolderId is set, specifies if the search should include its subfolders
  • MaxHits – How many items to return
  • Metadata – List of metadata objects.  The search will bring back documents that match all objects.
  • ReceivedFrom – User that modified the document
  • ShowRevisions – Determines if previous revisions should be returned
  • StartDate – Used in conjunction with EndDate to filter on modified dates
  • StartHitIndex – Index to start from when paging through results
  • Title – Name of the document
  • WithAllWords – Searches full text for documents with all words listed
  • WithoutWords – Searches full text for documents without the words listed
  • WithPhrase – Searches full text for documents with the given phrase

Vertical Tabs

c#
//The following code searches for documents based on a metadata group
//It will make multiple calls if there were more than 100 results returned
var searchDoc = new SCMSearchDocument();
var metadata = new SCMMetadata
{
	GroupName = "Invoices",
	FieldName = "Vendor Id",
	Value = "GJUY76"
};
 
searchDoc.Metadata = new[] {metadata};
searchDoc.StartHitIndex = 0;                        
searchDoc.MaxHits = 100;
SCMSearchResult result;
var returnList = new List<SCMDocument>();
do
{
	result = springCMService.DocumentPagedSearch(token, searchDoc,false);
	returnList.AddRange(result.DocResults);
	searchDoc.StartHitIndex += searchDoc.MaxHits;
} while (result.ThereMayBeMoreHits);
 
Console.WriteLine("{0} documents found by the search.",returnList.Count);
java
//The following code searches for documents based on a metadata group
//It will make multiple calls if there were more than 100 results returned
SCMSearchDocument searchDoc = new SCMSearchDocument();
 
 SCMMetadata metadata = new SCMMetadata();
 
 metadata.setGroupName("Invoices");
 metadata.setFieldName("Vendor Id");
 metadata.setValue("GJUY76");
 metadata.setDataType(SCMMetadataValueType.String);
 
 searchDoc.setMetadata(new SCMMetadata[] {metadata});
 searchDoc.setStartHitIndex(0);                        
 searchDoc.setMaxHits(100);
 searchDoc.setStartDate(Calendar.getInstance());
 searchDoc.setEndDate(Calendar.getInstance());
 
 SCMSearchResult result;
 ArrayList<SCMDocument> returnList = new ArrayList<SCMDocument>();
 
 do
 {
	 result = springCMService.documentPagedSearch(token, searchDoc,false);
	 returnList.addAll(Arrays.asList(result.getDocResults()));
	 searchDoc.setStartHitIndex(searchDoc.getStartHitIndex() + searchDoc.getMaxHits());
 } while (result.isThereMayBeMoreHits());
 
System.out.format("%s documents found by the search.\n",returnList.size());