Skip to content

Latest commit

 

History

History
57 lines (52 loc) · 2.44 KB

V1_search_space_content.md

File metadata and controls

57 lines (52 loc) · 2.44 KB
copyright link is
Copyright IBM Corp. 2017
search-for-space-content
future

Search for space content

This is a sample GraphQL query to search for messages across spaces to which you have access. Here we are requesting messages matching the string "interesting fact". The collection returned includes a maximum of 50 messages by default; this may be changed by passing an additional size parameter. If the total number of matching messages exceeds the number returned, successive pages of messages may be obtained using pageInfo (i.e., to get the next page, pass the endCursor from pageInfo as the after parameter on the next request).

Additional optional parameters may be included as follows:

  • locale: Locale string, e.g. en
  • searchFields: Message fields in which to search for the query string; defaults are content, annotation.content and annotation.file_name
  • from: Sender user ID(s)
  • in: Space ID(s)
  • dateFrom: Earliest timestamp to search
  • dateTo: Latest timestamp to search
{
  searchMessages(query: "interesting fact") {
    items {
      message {
        content
        contentType
        id
        created
        createdBy {
          displayName
        }
      }
      highlights {
        field
        highlighted
      }
      space {
        id
        title
      }
    }
    pageInfo {
      startCursor
      endCursor
      hasPreviousPage
      hasNextPage
    }
    total
  }
}

Try it out with our GraphQL tool - Search for Messages