Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence search API is returning fewer items than requested

Brian Levine March 5, 2019

Running Confluence 6.9.1

I am issuing the following REST request:

/rest/api/search?expand=content.history&cql=text~"widget" and type IN (page, blogpost, comment, attachment)&start=0&limit=1000&excerpt=indexed"


The actual number of matching documents is 107 and this is what is returned in the totalSize property of the response.

However, I actually receive only 53 items in this case, where items is the number of 'content' nodes in the result which also equals the value of the 'size' property of the result.  I would have expected to get 107.  In fact, no matter what I set limit to, I don't get that number of items returned.  If I set limit=10, I get back 4 items.  If I set no limit (which defaults to 25), I get back 11 items.  Start is always set to 0 in these tests.

Can anyone tell me what I'm doing wrong?

 

 

 

 

2 answers

1 accepted

1 vote
Answer accepted
Alex Medved _ConfiForms_
Community Champion
March 12, 2019

As far as I know the search API relies of Confluence search index and if this goes out of sync then the call starts to return incorrect data

Try rebuilding your Confluence search index: Content Index Administration

Brian Levine March 13, 2019

That appears to have been the problem.  Thank you @Alex Medved _ConfiForms_ ! I was running against one of our Confluence test instances.  So although I'm not quite sure why search index was out of sync, I'm not surprised.  After I rebuilt the index, I got the expected search results.

0 votes
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2019

Hi Brian,

I am not on the Confluence Team, but I will try to help.

I suspect that you need to encode some of that string to be url-safe.

eg.

/rest/api/search?expand=content.history&cql=text~%22widget%22%20and%20type%20IN%20%28page%2C%20blogpost%2C%20comment%2C%20attachment%29&start=0&limit=1000&excerpt=indexed"

I hope that helps!

Brian Levine March 5, 2019

Thanks, but I don't think this is the problem. The request URL is actually URL-encoded in some downstream code.  I showed the un-encoded URL for better readability.  I added some debug output to confirm that the URL is encoded before I make the request.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events