Upayavira, First of all, thanks for the answers.
We have considerer the possibily of doing several queries, however in hour case we want a count to show to the user (should take less than 2 seconds) and we could have millions of rows (being million of queries) to get this count. Isn't there any way to filter by the count? Something like, get all users where the number of corresponding documents in a join is lesser than X. Or all the users grouped by field F where count of records for field F is lesser than X... Or anything like that, regarding counts... Best regards, Marcelo Valle. 2013/9/30 Upayavira <u...@odoko.co.uk> > If your app and solr aren't far apart, you shouldn't be afraid of > multiple queries to solr per user request (I once discovered an app that > did 36 hits to solr per user request, and despite such awfulness of > design, no user ever complained about speed). > > You could do a query to solr for q=+user_id:X +date:[dateX TO dateY] to > find out how many docs, then take the numFound value, if it is above Y, > do a subsequent query to retrieve the docs, either all docs, or toes in > the relevant date range. > > Don't know if that helps. > > Upayavira > > On Sun, Sep 29, 2013, at 05:15 PM, Matheus Salvia wrote: > > Thanks for the anwser. Yes, you understood it correctly. > > The method you proposed should work perfectly, except I do have one more > > requirement that I forgot to mention earlier, and I apologize for that. > > The true problem we are facing is: > > * find all documents for userID=x, where userID=x has more than y > > documents in the index between dateA and dateB > > > > And since dateA and dateB can be any dates, its impossible to save the > > count, since we cannot foresee what date and what count will be > > requested. > > > > > > 2013/9/28 Upayavira <u...@odoko.co.uk> > > > > > To phrase your need more generically: > > > > > > * find all documents for userID=x, where userID=x has more than y > > > documents in the index > > > > > > Is that correct? > > > > > > If it is, I'd probably do some work at index time. First guess, I'd > keep > > > a separate core, which has a very small document per user, storing > just: > > > > > > * userID > > > * docCount > > > > > > Then, when you add/delete a document, you use atomic updates to either > > > increase or decrease the docCount on that user doc. > > > > > > Then you can use a pseudo join between these two cores relatively > > > easily. > > > > > > q=user_id:x {!join fromIndex=user from=user_id to=user_id}+user_id:x > > > +doc_count:[y TO *] > > > > > > Worst case, if you don't want to mess with your indexing code, I wonder > > > if you could use a ScriptUpdateProcessor to do this work - not sure if > > > you can have one add an entirely new, additional, document to the list, > > > but may be possible. > > > > > > Upayavira > > > > > > On Fri, Sep 27, 2013, at 09:50 PM, Matheus Salvia wrote: > > > > Sure, sorry for the inconvenience. > > > > > > > > I'm having a little trouble trying to make a query in Solr. The > problem > > > > is: > > > > I must be able retrieve documents that have the same value for a > > > > specified > > > > field, but they should only be retrieved if this value appeared more > than > > > > X > > > > times for a specified user. In pseudosql it would be something like: > > > > > > > > select user_id from documents > > > > where my_field="my_value" > > > > and > > > > (select count(*) from documents where my_field="my_value" and > > > > user_id=super.user_id) > X > > > > > > > > I Know that solr return a 'numFound' for each query you make, but I > dont > > > > know how to retrieve this value in a subquery. > > > > > > > > My Solr is organized in a way that a user is a document, and the > > > > properties > > > > of the user (such as name, age, etc) are grouped in another document > with > > > > a > > > > 'root_id' field. So lets suppose the following query that gets all > the > > > > root > > > > documents whose children have the prefix "some_prefix". > > > > > > > > is_root:true AND _query_:"{!join from=root_id > > > > to=id}requests_prefix:\"some_prefix\"" > > > > > > > > Now, how can I get the root documents (users in some sense) that have > > > > more > > > > than X children matching 'requests_prefix:"some_prefix"' or any other > > > > condition? Is it possible? > > > > > > > > P.S. It must be done in a single query, fields can be added at will, > but > > > > the root/children structure should be preserved (preferentially). > > > > > > > > > > > > 2013/9/27 Upayavira <u...@odoko.co.uk> > > > > > > > > > Mattheus, > > > > > > > > > > Given these mails form a part of an archive that are themselves > > > > > self-contained, can you please post your actual question here? > You're > > > > > more likely to get answers that way. > > > > > > > > > > Thanks, Upayavira > > > > > > > > > > On Fri, Sep 27, 2013, at 04:36 PM, Matheus Salvia wrote: > > > > > > Hello everyone, > > > > > > I'm having a problem regarding how to make a solr query, I've > posted > > > it > > > > > > on > > > > > > stackoverflow. > > > > > > Can someone help me? > > > > > > > > > > > > > > > http://stackoverflow.com/questions/19039099/apache-solr-count-of-subquery-as-a-superquery-parameter > > > > > > > > > > > > Thanks in advance! > > > > > > > > > > > > -- > > > > > > -- > > > > > > // Matheus Salvia > > > > > > Desenvolvedor Mobile > > > > > > Celular: +55 11 9-6446-2332 > > > > > > Skype: meta.faraday > > > > > > > > > > > > > > > > > > > > > -- > > > > -- > > > > // Matheus Salvia > > > > Desenvolvedor Mobile > > > > Celular: +55 11 9-6446-2332 > > > > Skype: meta.faraday > > > > > > > > > > > -- > > -- > > // Matheus Salvia > > Desenvolvedor Mobile > > Celular: +55 11 9-6446-2332 > > Skype: meta.faraday >