Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-61268

Allow for exact text string matches using the REST API CQL search endpoint

XMLWordPrintable

    • 0
    • 3
    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      Using our API search endpoints does not allow for exact/literal string matches on text fields. The CQL text search only allows the ~ & !~ contains/does not contain operators as indicated in our CQL Field Reference for text:

      Example: This will find any page with those words in any order
      GET /rest/api/content/search?cql=text~"example exact search string"
      GET /rest/api/search?cql=text~"example exact search string"
      • Example page:
      • From the UI you can perform a exact search by enclosing your search term in quotes:

        Workaround

        Please note this is using an internal API that is not directly supported and may be subject to change. For our public REST API please refer to: https://docs.atlassian.com/ConfluenceServer/rest/7.11.0/

      You can perform a exact search in the Confluence UI Advanced search as per normal and grab the internal API used for the search from the browser developer tools, for example:

      <baseURL>/rest/searchv3/1.0/cqlSearch?cql=siteSearch+~+%22%5C%22<SEARCH>+<TERMS>+<HERE>%5C%22%22+and+type+in+(%22space%22%2C%22user%22%2C%22page%22%2C%22blogpost%22%2C%22comment%22)
      

      As in the example screenshot with the text This exact sentence.

      Seaching "This exact sentence"
      # I Removed the start and end of the command above just to make it easier to read what needs updating.
      ...siteSearch+~+%22%5C%22this+exact+sentence%5C%22%22...
      
         "start": 0,
          "limit": 25,
          "size": 1,
          "totalSize": 1,
          "cqlQuery": "siteSearch ~ \"\\\"this exact sentence\\\"\" and type in (\"space\",\"user\",\"page\",\"blogpost\",\"comment\")",
      Zero match when search term is not exact and does NOT work in the UI
       also "results": [], 
       "start": 0,
       "limit": 25,
       "size": 0,
       "totalSize": 0,
       "cqlQuery": "siteSearch ~ "\"this sentence exact\"" and type in ("space","user","page","blogpost","comment")",
      

      So it is currently possible to still replicate the UI results but there is no native way without a workaround.

              Unassigned Unassigned
              dmark@atlassian.com Danny (Inactive)
              Votes:
              5 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: