Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr: Check if a document exists without retrieving the document

Tags:

php

nosql

solr

I need to find out if a document exists but the documents saved in the Solr server are pretty big so if I do a classic search to retrieve the document with a specified id and the document is returned it takes too much time to process. Is there a possibility to return for example the number of matching documents without retrieving the actual documents ?

like image 933
Daniel Luca CleanUnicorn Avatar asked Jan 16 '23 05:01

Daniel Luca CleanUnicorn


1 Answers

Yes, this is possible. You can set rows=0 when submitting a query, execute it. No actual documents are returned.

In the response, you can read the numFound attribute from response. If numFound=1 (since this is for ID), then the document is found.

like image 137
user1452132 Avatar answered Jan 19 '23 00:01

user1452132