lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikhail Khludnev <>
Subject Re: Is complex query like this possible?
Date Wed, 01 Feb 2012 18:33:41 GMT
Hello Sergey,

if your docs looks like:

you can search it:
+PATH:test1 +FILES:jpg

2012/2/1 Sergei Ananko <>

> Hello,
> We use Solr to search over a filesystem, so there are a lot of files and
> folders indexed, name and path of each file are stored in different fields.
> The task is to find folders by name AND containing at least one file of
> specific type somewhere inside. For example, we search by phrase "test" and
> for JPG files and have two folders:
> 1) "test1" - empty folder
> 2) "test2" - contains 1 file "abcd.jpg" inside.
> Search result must only contain folder "test2", because "test1" does not
> correspond to second criteria.
> SQL equivalent of such search query looks like:
> SELECT * FROM indexed_files t1 WHERE LIKE '%test%' AND (SELECT
> COUNT(*) FROM indexed_files t2 WHERE t2.path LIKE CONCAT(t1.path, '%') AND
> LIKE '%jpg') > 0;
> The question is: is it possible to do such search in Solr by single query?
> Single query is important because we need to use Solr's paging ("start" and
> "rows" parameters), so we should avoid filtering of wrong results in our
> code. I've read Solr wiki about nested queries but haven't found a way to
> do it. BTW, does Solr provide equivalent of "SELECT COUNT(*)" statement to
> access count of found records directly in Solr query? Or such complex query
> is completely impossible?
> --
> Best regards,
>  Asv                

Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message