Harvard Health Content External Web Service Documentation
SearchContent Method
This Method will return a small amount of meta-data for each content object that matches the supplied criteria.
For content to be included in the search results, it must match every one of the specified criteria. For multi-valued criteria, the content object must match at least one of the supplied values within that specific criteria.
Parameters: XmlRequest
<SearchCriteria SortBy="[PublishedDate, Title]" SortDirection="[Ascending, Descending]" >
<Paging PageSize="[int]" PageNumber="[int]" />
<FullText LogicalOperator="[And,Or]">[string(s)]</FullText>
<ByTitle IncludeAdditionalTitles="[true, false]">[Title]</ByTitle>
<ByLetter IncludeAdditionalTitles="[true, false]">[Single Character]</ByLetter>
<LastModifiedDate>mm/dd/yyyy</LastModifiedDate>
<EndLastModifiedDate>mm/dd/yyyy</EndLastModifiedDate>
<Gender>[All, Male, Female]</Gender>
<AgeGroups>
<AgeGroup>[Infant (0 - 11 mo), Childhood (11 mo - 12 yrs), Teen (12 - 18 yrs), Adult (18+), Senior]</AgeGroup>
</AgeGroups>
<ContentTypes>
<ContentType ContentTypeId="[int]"/>
<ContentType ContentTypeId="[int]"/>
</ContentTypes>
</SearchCriteria>
At least one of the SearchCriteria child elements is required; a request with just <SearchCriteria /> will result in an error. The order of the elements is not important
The optional SortBy and SortDirection attributes are used to return a specific sorting of the content. Options for SortBy are PublishedDate and Title. By default all but Title are sorted in descending order. To return a different sort direction use SortDirection with the value of either Ascending or Descending. If SortDirection is provided without a SortBy then this attribute is ignored.
The FullText element specifies the word list to match in the content. Body is the field that is searched. The required attribute LogicalOperator specifies how the word list is treated in the search; a value of "And" means that all words in the word list must match, a value of "Or" means that one or more of the words in the word list must match. Quoted phrases may also be included:
<SearchCriteria>
<FullText LogicalOperator="And">"heart disease" liver</FullText>
</SearchCriteria>
The ByLetter element specifies a letter to filter the search results by. If a content object's title begins with the designated letter, the content object will be returned in the results. This element also recognizes "#" as a valid letter and will return content objects that begin with a number if specified.
The LastModifiedDate element specifies the date to match in the content's LastModifiedDate field. The format of this content is defined by the XML Schema and is in the format YYYY-MM-DD.
The EndLastModifiedDate element, specified with the LastModifiedDate element, defines a range of dates to match in the content's LastModifiedDate field. If EndLastModifiedDate is specified but LastModifiedDate is not, EndLastModifiedDate is ignored. If LastModifiedDate is specified but EndPostingDate is not, the date must match exactly. If they are both specified, the date must be between the two supplied dates.
The PostingDate and EndPostingDate elements have been deprecated.
The Gender element specifies the gender to match in the content's Gender field. Current options for this element are "All", "Female", and "Male". Specifying "All" is different than leaving this element out. When <Gender>All</Gender> is specified, only those content objects which apply to both men and women are returned. If the criterion is omitted, content objects which apply to just men, just women or men and women are returned.
The AgeGroups element specifies the age categories to limit the search by. Current options for AgeGroup are:
- Infant (0 - 11 mo)
- Childhood (11 mo - 12 yrs)
- Teen (12 - 18 yrs)
- Adult (18+)
- Senior
Multiple age groups can be supplied and content can be mapped to multiple age groups. For instance if the search is limited to "Senior", and a particular content object was mapped to Teen, Adult and Senior, it would be returned, but content mapped only to Adult would not. If the search criteria were both Infant and Childhood, and content was mapped to Childhood and Teen, it would be returned.
The ContentTypes element specifies the list of ContentTypeIds to limit the search by. Multiple ContentType elements can be used. For instance, to search only through news, use <ContentTypes><ContentType ContentTypeId="6"/></ContentTypes>. To search through news and the wellness library, use <ContentTypes><ContentType ContentTypeId="6"/> <ContentType ContentTypeId="1"/></ContentTypes>. A list of all available content type IDs can be provided on request.
A Paging element can be used in the request to limit the number of items to be returned in pages. <Paging PageNumber="1" PageSize="10" />. Where PageNumber tells the web service which page of data to return and PageSize is used to specify the number of content objects per page. If the Paging element is included in the request, the result XML will include paging information in the ContentList element: <ContentList PageNumber="1" PageSize="10" TotalPages="5" TotalContent="53">
Search Request template
http://www.content.health.harvard.edu/[SiteName]/Content.svc/SearchContent?xmlRequest=[SearchCriteria]
Sample values for [SearchCriteria]
Return all licensed content containing the words "pain" and "angina"
<SearchCriteria><FullText LogicalOperator="And">pain angina</FullText></SearchCriteria>
Return all licensed content containing either "pain" or "angina" or both:
<SearchCriteria><FullText LogicalOperator="Or">pain angina</FullText></SearchCriteria>
Return all licensed content containing "heart" in the title:
<SearchCriteria><ByTitle>heart</ByTitle></SearchCriteria>
Return all licensed content of ContentType 1 or 2:
<SearchCriteria><ContentTypes><ContentType ContentTypeId="1"/><ContentType ContentTypeId="2"/></ContentTypes></SearchCriteria>
Return all licensed content with a PostingDate of January 1, 2004:
<SearchCriteria><PostingDate>2004-01-01</PostingDate></SearchCriteria>
Return all licensed content of ContentType 1 containing "heart" in the title and "pain" in the body:
<SearchCriteria><ContentTypes><ContentType ContentTypeId="1"/></ContentTypes><ByTitle>heart</ByTitle> <FullText LogicalOperator="And">pain</FullText></SearchCriteria>
Sample Search Request
http://www.content.health.harvard.edu/[SiteName]/Content.svc/SearchContent?xmlRequest=<SearchCriteria><ByTitle>heart</ByTitle></SearchCriteria>
Sample Result XML
<?xml version="1.0" encoding="utf-8"?>
<ContentList PageNumber="1" PageSize="10" TotalPages="5" TotalContent="53">
<ContentObject ContentObjectType="Document" ContentTypeId="1" ContentId="1" IsCustom="false" ViewCount="0">
<Language Code="en"/>
<RegularTitle>Helping the Heart Through Cardiac Rehab</RegularTitle>
<Gender>All</Gender>
</ContentObject>
<ContentObject ContentObjectType="Document" ContentTypeId="6" ContentId="514918" IsCustom="false" ViewCount="0">
<Language code="en"/>
<RegularTitle>New Hope for People With Heart Failure</RegularTitle>
<Gender>All</Gender>
<PostingDate>2003-09-03T00:00:00.0000000-06:00</PostingDate>
<LastModifiedDate>2003-09-03T00:00:00.0000000-06:00</LastModifiedDate>
</ContentObject>
</ContentList>