Hello, it sounds like FieldCollapsing or Join scenarios, but given the only information which you provided, it can be solved by indexing statuses as multivalue field: -ID- -STATUS- id1 (1 2 3 4) id2 (1 2) id3 (1)
q=*:*&fq=STATUS:1&fq=NOT STATUS:3 On Mon, Jul 15, 2013 at 3:19 PM, EquilibriumCST <valeri_ho...@abv.bg> wrote: > Hi all, > > I have the following case. > > Solr documents has fields --> id and status. Id is not unique. Unique is > the > combination of these two elements. > Documents with same id have different statuses. > > List of Documents > > -ID- -STATUS- > id1 1 > id1 2 > id1 3 > id1 4 > id2 1 > id2 2 > id3 1 > > I need to make query that takes all documents with specific status and to > exclude documents that don't have other specific status. > As an example I need to get all documents with status 2 and don't have > status 3. > The expected result should be document : > id2 2 > > Another example: all documents with status 1 and don't have status 3. Then > the result should be: > id2 1 > id3 1 > > Here is my query that don't work > > http://192.168.130.14:13080/solr/select/?q=status:1&version=2.2&start=0&rows=10&indent=on&fl=id,status&fq=-id:(*:*%20AND%20status:2) > The problem is in filter query(fq) part. In fq must be the ids of the > documents with status 2 and if the current document id is in this list to > be > excluded. > I guess some subquery must be used in fq part or something else. > Just for information we are using APACHE SOLR 3.6 and document count is > around 100k. > > Thanks in advance! > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Nested-query-in-SOLR-filter-query-fq-tp4078020.html > Sent from the Solr - User mailing list archive at Nabble.com. > -- Sincerely yours Mikhail Khludnev Principal Engineer, Grid Dynamics <http://www.griddynamics.com> <mkhlud...@griddynamics.com>