# Search using search api sometimes results in empty responses

**URL:** <https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286>\
**Category:** Sonatype Nexus Repository\
**Created:** [September 12, 2022, 4:04am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286 "2022-09-12T04:04:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![d3-ito](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@d3-ito](https://community.sonatype.com/u/d3-ito)\
**Post date:** [September 12, 2022, 4:04am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/1 "2022-09-12T04:04:18Z")

</div>

Hello.  
I have a question about a problem I am having with the search api on nexus 3.

When using the search api on sonatype nexus 3 and performing a command line search as follows, the results may be empty even though the file exists on nexus.

curl -u : https://\<nexus’s domain\>/service/rest/v1/search/assets?repository=&group=\<group\_name\>&q=\<query\_keyword\>

Example response on success:.  
{  
“items” : [ {  
“downloadUrl” : "https://\<nexus’s domain\>/repository/\<repository\_name\>/\<group\_name\>/\<module\_name\>,  
“path” : “\<group\_name\>/\<module\_name\>”,  
“id” : “bGNpLXN0YXItYXBpLXJhdy1yZWxlYXNlOjJlMjBkODc0YWIxM2YwZDI5ZTU4N2JkOWM4NzE5MTUx”,  
“repository” : “\<repository\_name\>”,  
“format” : “raw”,  
“checksum” : {  
“sha1” : “8007fe3734db3d67b9f95e41071af79bff28d637”,  
“md5” : “c9bcc0b3359b6bd1ba6a376ebe77e64b”  
}  
} ],  
“continuationToken” : null  
}

Example response when empty:.  
{  
“items” : [],  
“continuationToken” : null  
}

If the response is empty, after logging in to nexus and downloading that file from the screen (GUI), the search results on the command line will respond correctly.

I am having trouble finding the cause of this problem. Can anyone give me some advice on this?  
Has anyone ever experienced a similar event?

---

<div class="post-metadata">

**Author:** ![mpiggott](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mpiggott](https://community.sonatype.com/u/mpiggott)\
**Post date:** [September 12, 2022, 1:58pm UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/2 "2022-09-12T13:58:21Z")

</div>

Is it a proxy repository? Nexus REST API (and UI) only includes content on the server.

---

<div class="post-metadata">

**Author:** ![d3-ito](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@d3-ito](https://community.sonatype.com/u/d3-ito)\
**Post date:** [September 13, 2022, 12:46am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/3 "2022-09-13T00:46:10Z")

</div>

Thank you for your comment.  
It is a raw repository, not a proxy repository.

---

<div class="post-metadata">

**Author:** ![mmartz](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mmartz](https://community.sonatype.com/u/mmartz)\
**Post date:** [September 13, 2022, 12:53am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/4 "2022-09-13T00:53:16Z")

</div>

You mean it’s a raw hosted repository? You can still have raw proxy repositories.

---

<div class="post-metadata">

**Author:** ![d3-ito](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@d3-ito](https://community.sonatype.com/u/d3-ito)\
**Post date:** [September 13, 2022, 3:12am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/5 "2022-09-13T03:12:32Z")

</div>

Yes, it’s a raw hosted repository.  
If the search for a file fails, after logging into nexus and downloading that file on the screen, the search for the file will succeed.  
Based on the above facts, we suspect that there is a time lag until the elasticsearch index is generated, or there is some other event that is causing the failure.

---

<div class="post-metadata">

**Author:** ![mpiggott](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mpiggott](https://community.sonatype.com/u/mpiggott)\
**Post date:** [September 13, 2022, 12:38pm UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/6 "2022-09-13T12:38:37Z")

</div>

The search index is updated asynchronously and may take several seconds.

---

<div class="post-metadata">

**Author:** ![d3-ito](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@d3-ito](https://community.sonatype.com/u/d3-ito)\
**Post date:** [September 26, 2022, 1:52am UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/7 "2022-09-26T01:52:33Z")

</div>

Thank you for your response.  
Sometimes the response is null after a few hours or so, not a few seconds.  
If you could advise us of any log information that we should investigate, we would be very grateful.

---

<div class="post-metadata">

**Author:** ![jonathanmedd](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/jonathanmedd/32/2485_2.png) [@jonathanmedd](https://community.sonatype.com/u/jonathanmedd)\
**Post date:** [November 16, 2022, 6:24pm UTC](https://community.sonatype.com/t/search-using-search-api-sometimes-results-in-empty-responses/9286/8 "2022-11-16T18:24:57Z")

</div>

We had the exact same reproducible issue after restarting our Nexus 3.38.1 instance, so thanks for posting this.

We updated our container instance to 3.43.0. Upon startup of the container the log was full of updating index messages. Once they completed all of our searches brought back a full set of results again.
