HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

Paragraph Search

The /layar/paragraph/search endpoint allows you to interact with paragraphs in Layar, giving you increased granularity into your documents.

Setting Up

Make sure you have already followed the instructions for importing dependencies and authentication from the Getting Started Guide. You can use your token variable to authenticate your requests.


Check Your Imported Modules

Make sure you have imported the requests and json module before proceeding with this guide.

Configuring Your Header

We will be using the same header that we used in the previous section Document Search Pre-Reqs.

header = {'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {token}",
          'X-Vyasa-Client': 'layar',
          'X-Vyasa-Data-Providers' : 'sandbox.certara.ai'}

Setting Your Filters

As with document search there is going to be values, we can forward in the body of the request. There are various values you can use. These values can be found at https://YOUR_LAYAR_ENVIRONMENT/layar/swagger-ui.html.

Filter By Query

The generic search you would do, is look for specific text in a paragraph. We will use the q value in the body.

body = {
  			'q' :'QUERY TEXT HERE'

Filter By Document IDs

You can then filter this even further by focusing on specific set of documents using the documentIds value.

body = {
  			'q' :'QUERY TEXT HERE',
  			'documentIds' : ['docId1' , 'docId2'

Filter By Dates

You can filter by the date the paragraph object was created, using the fromDate and toDate values.

body = {
  			'q' :'QUERY TEXT HERE',
  			'fromDate' : '2021-05-01',
        'toDate' : '2023-09-30'

Highlight Query Results

You can highlight the specific text you find in paragraphs using the highlight which is a boolean value.

body = {
  			'q' :'QUERY TEXT HERE',
  			'fromDate' : '2021-05-01',
        'toDate' : '2023-09-30',
  			'highlight' : True

Perform the Search

As with all API calls in Python we will be using requests to do a POST. Our header authenticating and dictating which data providers we want to look at. While the body holds the query and relevant filters.

paraSearchUri = f'{envUrl}/layar/paragraph/search'

response = requests.post(paraSearchUri,
                         headers = header,
                         json = body
pprint(response) #optional

Up Next

Now that we know how to search for specific paragraphs, we can move onto searching for specific statements.